From 06d9556f13384ebf6eede6e0a38a7dd48cbe26eb Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Fri, 6 Jul 2018 22:25:49 +0200 Subject: [PATCH 01/85] Added http module draft --- .../languages/TypeScriptClientCodegen.java | 587 ++++++++++++++++++ .../org.openapitools.codegen.CodegenConfig | 1 + .../main/resources/typescript/README.mustache | 1 + .../resources/typescript/http/http.mustache | 43 ++ .../typescript/http/isomorphic-fetch.mustache | 27 + .../resources/typescript/package.mustache | 33 + .../resources/typescript/tsconfig.mustache | 29 + 7 files changed, 721 insertions(+) create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java create mode 100644 modules/openapi-generator/src/main/resources/typescript/README.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/http/http.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/package.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java new file mode 100644 index 000000000000..76df02a6caed --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -0,0 +1,587 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.languages; + +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.NumberSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.parameters.Parameter; +import org.apache.commons.lang3.StringUtils; +import org.openapitools.codegen.*; +import org.openapitools.codegen.utils.ModelUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.*; + +public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { + private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptClientCodegen.class); + + private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value"; + private static final String UNDEFINED_VALUE = "undefined"; + + protected String modelPropertyNaming = "camelCase"; + protected boolean supportsES6 = true; + protected HashSet languageGenericTypes; + + public TypeScriptClientCodegen() { + super(); + + // clear import mapping (from default generator) as TS does not use it + // at the moment + importMapping.clear(); + outputFolder = "generated-code/typescript"; + embeddedTemplateDir = templateDir = "typescript"; + + supportsInheritance = true; + + // NOTE: TypeScript uses camel cased reserved words, while models are title cased. We don't want lowercase comparisons. + reservedWords.addAll(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<>(Arrays.asList( + "string", + "String", + "boolean", + "Boolean", + "Double", + "Integer", + "Long", + "Float", + "Object", + "Array", + "Date", + "number", + "any", + "File", + "Error", + "Map" + )); + + languageGenericTypes = new HashSet(Arrays.asList( + "Array" + )); + + instantiationTypes.put("array", "Array"); + + typeMapping = new HashMap(); + 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("date", "string"); + typeMapping.put("DateTime", "Date"); + typeMapping.put("binary", "any"); + typeMapping.put("File", "any"); + typeMapping.put("ByteArray", "string"); + typeMapping.put("UUID", "string"); + typeMapping.put("Error", "Error"); + + 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")); + // TODO: gen package.json? + + //Files for building our lib + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); + supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); + supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); + supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts")); + } + + + @Override + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + @Override + public String escapeReservedWord(String name) { + if (this.reservedWordsMappings().containsKey(name)) { + return this.reservedWordsMappings().get(name); + } + return "_" + name; + } + + @Override + public String toParamName(String name) { + // should be the same as variable name + return toVarName(name); + } + + @Override + public String toVarName(String name) { + // sanitize name + name = sanitizeName(name); + + if ("_".equals(name)) { + name = "_u"; + } + + // if it's all uppper case, do nothing + if (name.matches("^[A-Z_]*$")) { + return name; + } + + name = getNameUsingModelPropertyNaming(name); + + // for reserved word or word starting with number, append _ + if (isReservedWord(name) || name.matches("^\\d.*")) { + name = escapeReservedWord(name); + } + + return name; + } + + @Override + 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(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; + } + + if (languageSpecificPrimitives.contains(name)) { + String modelName = camelize("model_" + name); + LOGGER.warn(name + " (model name matches existing language type) cannot be used as a 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 + protected String getParameterDataType(Parameter parameter, Schema p) { + // handle enums of various data types + Schema inner; + if (ModelUtils.isArraySchema(p)) { + ArraySchema mp1 = (ArraySchema) p; + inner = mp1.getItems(); + return this.getSchemaType(p) + "<" + this.getParameterDataType(parameter, inner) + ">"; + } else if (ModelUtils.isMapSchema(p)) { + inner = (Schema) p.getAdditionalProperties(); + return "{ [key: string]: " + this.getParameterDataType(parameter, inner) + "; }"; + } else if (ModelUtils.isStringSchema(p)) { + // Handle string enums + if (p.getEnum() != null) { + return enumValuesToEnumTypeUnion(p.getEnum(), "string"); + } + } else if (ModelUtils.isIntegerSchema(p)) { + // Handle integer enums + if (p.getEnum() != null) { + return numericEnumValuesToEnumTypeUnion(new ArrayList(p.getEnum())); + } + } else if (ModelUtils.isNumberSchema(p)) { + // Handle double enums + if (p.getEnum() != null) { + return numericEnumValuesToEnumTypeUnion(new ArrayList(p.getEnum())); + } + } + /* TODO revise the logic below + else if (ModelUtils.isDateSchema(p)) { + // Handle date enums + DateSchema sp = (DateSchema) p; + if (sp.getEnum() != null) { + return enumValuesToEnumTypeUnion(sp.getEnum(), "string"); + } + } else if (ModelUtils.isDateTimeSchema(p)) { + // Handle datetime enums + DateTimeSchema sp = (DateTimeSchema) p; + if (sp.getEnum() != null) { + return enumValuesToEnumTypeUnion(sp.getEnum(), "string"); + } + }*/ + return this.getTypeDeclaration(p); + } + + /** + * Converts a list of strings to a literal union for representing enum values as a type. + * Example output: 'available' | 'pending' | 'sold' + * + * @param values list of allowed enum values + * @param dataType either "string" or "number" + * @return a literal union for representing enum values as a type + */ + protected String enumValuesToEnumTypeUnion(List values, String dataType) { + StringBuilder b = new StringBuilder(); + boolean isFirst = true; + for (String value : values) { + if (!isFirst) { + b.append(" | "); + } + b.append(toEnumValue(value.toString(), dataType)); + isFirst = false; + } + return b.toString(); + } + + /** + * Converts a list of numbers to a literal union for representing enum values as a type. + * Example output: 3 | 9 | 55 + * + * @param values a list of numbers + * @return a literal union for representing enum values as a type + */ + protected String numericEnumValuesToEnumTypeUnion(List values) { + List stringValues = new ArrayList<>(); + for (Number value : values) { + stringValues.add(value.toString()); + } + return enumValuesToEnumTypeUnion(stringValues, "number"); + } + + @Override + public String toDefaultValue(Schema p) { + if (ModelUtils.isBooleanSchema(p)) { + return UNDEFINED_VALUE; + } else if (ModelUtils.isDateSchema(p)) { + return UNDEFINED_VALUE; + } else if (ModelUtils.isDateTimeSchema(p)) { + return UNDEFINED_VALUE; + } else if (ModelUtils.isNumberSchema(p)) { + if (p.getDefault() != null) { + return p.getDefault().toString(); + } + return UNDEFINED_VALUE; + } else if (ModelUtils.isIntegerSchema(p)) { + if (p.getDefault() != null) { + return p.getDefault().toString(); + } + return UNDEFINED_VALUE; + } else if (ModelUtils.isStringSchema(p)) { + if (p.getDefault() != null) { + return "'" + (String) p.getDefault() + "'"; + } + return UNDEFINED_VALUE; + } else { + return UNDEFINED_VALUE; + } + + } + + @Override + protected boolean isReservedWord(String word) { + // NOTE: This differs from super's implementation in that TypeScript does _not_ want case insensitive matching. + return reservedWords.contains(word); + } + + @Override + public String getSchemaType(Schema p) { + String openAPIType = super.getSchemaType(p); + String type = null; + if (typeMapping.containsKey(openAPIType)) { + type = typeMapping.get(openAPIType); + if (languageSpecificPrimitives.contains(type)) + return type; + } else + type = openAPIType; + return toModelName(type); + } + + @Override + public String toOperationId(String operationId) { + // throw exception if method name is empty + if (StringUtils.isEmpty(operationId)) { + throw new RuntimeException("Empty method name (operationId) not allowed"); + } + + // method name cannot use reserved keyword, e.g. return + // append _ at the beginning, e.g. _return + if (isReservedWord(operationId)) { + return escapeReservedWord(camelize(sanitizeName(operationId), true)); + } + + return camelize(sanitizeName(operationId), true); + } + + public void setModelPropertyNaming(String naming) { + if ("original".equals(naming) || "camelCase".equals(naming) || + "PascalCase".equals(naming) || "snake_case".equals(naming)) { + this.modelPropertyNaming = naming; + } else { + throw new IllegalArgumentException("Invalid model property naming '" + + naming + "'. Must be 'original', 'camelCase', " + + "'PascalCase' or 'snake_case'"); + } + } + + public String getModelPropertyNaming() { + return this.modelPropertyNaming; + } + + public String getNameUsingModelPropertyNaming(String name) { + switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) { + case original: + return name; + 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'"); + } + + } + + @Override + public String toEnumValue(String value, String datatype) { + if ("number".equals(datatype)) { + return value; + } else { + return "\'" + escapeText(value) + "\'"; + } + } + + @Override + public String toEnumDefaultValue(String value, String datatype) { + return datatype + "_" + value; + } + + @Override + public String toEnumVarName(String name, String datatype) { + if (name.length() == 0) { + return "Empty"; + } + + // for symbol, e.g. $, # + if (getSymbolName(name) != null) { + return camelize(getSymbolName(name)); + } + + // number + if ("number".equals(datatype)) { + String varName = "NUMBER_" + name; + + varName = varName.replaceAll("-", "MINUS_"); + varName = varName.replaceAll("\\+", "PLUS_"); + varName = varName.replaceAll("\\.", "_DOT_"); + return varName; + } + + // string + String enumName = sanitizeName(name); + enumName = enumName.replaceFirst("^_", ""); + enumName = enumName.replaceFirst("_$", ""); + + // camelize the enum variable name + // ref: https://basarat.gitbooks.io/typescript/content/docs/enums.html + enumName = camelize(enumName); + + if (enumName.matches("\\d.*")) { // starts with number + return "_" + enumName; + } else { + return enumName; + } + } + + @Override + public String toEnumName(CodegenProperty property) { + String enumName = toModelName(property.name) + "Enum"; + + if (enumName.matches("\\d.*")) { // starts with number + return "_" + enumName; + } else { + return enumName; + } + } + + @Override + public Map postProcessModels(Map objs) { + // process enum in models + List models = (List) postProcessModelsEnum(objs).get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + cm.imports = new TreeSet(cm.imports); + // name enum with model name, e.g. StatusEnum => Pet.StatusEnum + for (CodegenProperty var : cm.vars) { + if (Boolean.TRUE.equals(var.isEnum)) { + var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName); + } + } + if (cm.parent != null) { + for (CodegenProperty var : cm.allVars) { + if (Boolean.TRUE.equals(var.isEnum)) { + var.datatypeWithEnum = var.datatypeWithEnum + .replace(var.enumName, cm.classname + "." + var.enumName); + } + } + } + } + + return objs; + } + + @Override + public Map postProcessAllModels(Map objs) { + Map result = super.postProcessAllModels(objs); + + for (Map.Entry entry : result.entrySet()) { + Map inner = (Map) entry.getValue(); + List> models = (List>) inner.get("models"); + for (Map mo : models) { + CodegenModel cm = (CodegenModel) mo.get("model"); + if (cm.discriminator != null && cm.children != null) { + for (CodegenModel child : cm.children) { + this.setDiscriminatorValue(child, cm.discriminator.getPropertyName(), this.getDiscriminatorValue(child)); + } + } + } + } + return result; + } + + public void setSupportsES6(Boolean value) { + supportsES6 = value; + } + + public Boolean getSupportsES6() { + return supportsES6; + } + + private void setDiscriminatorValue(CodegenModel model, String baseName, String value) { + for (CodegenProperty prop : model.allVars) { + if (prop.baseName.equals(baseName)) { + prop.discriminatorValue = value; + } + } + if (model.children != null) { + final boolean newDiscriminator = model.discriminator != null; + for (CodegenModel child : model.children) { + this.setDiscriminatorValue(child, baseName, newDiscriminator ? value : this.getDiscriminatorValue(child)); + } + } + } + + private String getDiscriminatorValue(CodegenModel model) { + return model.vendorExtensions.containsKey(X_DISCRIMINATOR_TYPE) ? + (String) model.vendorExtensions.get(X_DISCRIMINATOR_TYPE) : model.classname; + } + + @Override + public String escapeQuotationMark(String input) { + // remove ', " to avoid code injection + return input.replace("\"", "").replace("'", ""); + } + + @Override + public String escapeUnsafeCharacters(String input) { + return input.replace("*/", "*_/").replace("/*", "/_*"); + } + + @Override + public String getName() { + return "typescript"; + } + + @Override + public String getHelp() { + return "Generates a TypeScript client library using Fetch API (beta)."; + } + + + @Override + public void processOpts() { + super.processOpts(); + + if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) { + setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING)); + } + + if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) { + setSupportsES6(Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString())); + additionalProperties.put("supportsES6", getSupportsES6()); + } + + // change package names + apiPackage = this.apiPackage + ".apis"; + modelPackage = this.modelPackage + ".models"; + testPackage = this.testPackage + ".tests"; + } + + @Override + public String getTypeDeclaration(Schema p) { + Schema inner; + if (ModelUtils.isArraySchema(p)) { + inner = ((ArraySchema) p).getItems(); + return this.getSchemaType(p) + "<" + this.getTypeDeclaration(inner) + ">"; + } else if (ModelUtils.isMapSchema(p)) { + inner = (Schema) p.getAdditionalProperties(); + return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; + } else if (ModelUtils.isFileSchema(p)) { + return "any"; + } else if (ModelUtils.isBinarySchema(p)) { + return "any"; + } else { + return super.getTypeDeclaration(p); + } + } + + @Override + protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) { + codegenModel.additionalPropertiesType = getTypeDeclaration((Schema) schema.getAdditionalProperties()); + addImport(codegenModel, codegenModel.additionalPropertiesType); + } +} diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 8e2db93db510..893113e32edf 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -113,6 +113,7 @@ org.openapitools.codegen.languages.SwiftClientCodegen org.openapitools.codegen.languages.Swift3Codegen org.openapitools.codegen.languages.Swift4Codegen org.openapitools.codegen.languages.Swift5ClientCodegen +org.openapitools.codegen.languages.TypeScriptClientCodegen org.openapitools.codegen.languages.TypeScriptAngularClientCodegen org.openapitools.codegen.languages.TypeScriptAngularJsClientCodegen org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen diff --git a/modules/openapi-generator/src/main/resources/typescript/README.mustache b/modules/openapi-generator/src/main/resources/typescript/README.mustache new file mode 100644 index 000000000000..ea786ff2cf69 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/README.mustache @@ -0,0 +1 @@ +readme \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache new file mode 100644 index 000000000000..f5bbf2df97d1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -0,0 +1,43 @@ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +export class Request { + public headers: { [key: string]: string } = {}; + public body: string = ""; + + public constructor(public url: string, public httpMethod: HttpMethod) { + + } + + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeader(key: string, value: string): void { + this.headers[key] = value; + } +} + +export class Response { + + public constructor(public httpStatusCode: number, + public headers: { [key: string]: string }, public body: string) { + } + +} + +export interface HttpLibrary { + send(request: Request): Promise; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache new file mode 100644 index 000000000000..69aaffd071e6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -0,0 +1,27 @@ +import {HttpLibrary, Request, Response} from './http'; +import * as e6p from 'es6-promise' +e6p.polyfill(); +import 'isomorphic-fetch'; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: Request): Promise { + let method = request.httpMethod.toString(); + return fetch(request.url, { + method: method, + body: request.body, + headers: request.headers, + credentials: "same-origin" + }).then((resp) => { + // hack + let headers = (resp.headers as any)._headers; + for (let key in headers) { + headers[key] = (headers[key] as Array).join("; "); + } + + return resp.text().then((body) => { + return new Response(resp.status, headers, body) + }); + }); + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache new file mode 100644 index 000000000000..327f133bcebc --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -0,0 +1,33 @@ +{ + "name": "{{npmName}}", + "version": "{{npmVersion}}", + "description": "OpenAPI client for {{npmName}}", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator", + "{{npmName}}" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "es6-promise": "^4.2.4", + "isomorphic-fetch": "^2.2.1", + "@types/isomorphic-fetch": "0.0.34" + }, + "devDependencies": { + "typescript": "^2.9.2" + }{{#npmRepository}},{{/npmRepository}} +{{#npmRepository}} + "publishConfig":{ + "registry":"{{npmRepository}}" + } +{{/npmRepository}} +} diff --git a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache new file mode 100644 index 000000000000..6223bc4d7cfa --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", + "module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": true, /* Report errors on unused locals. */ + "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "declaration": true, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file From 05f64c673221299f1a6bef545747f01639b87a42 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 9 Aug 2018 17:36:24 +0200 Subject: [PATCH 02/85] Added generic enum --- .../resources/typescript/http/http.mustache | 10 ++++- .../typescript/http/isomorphic-fetch.mustache | 13 +++++- .../typescript/models/modelEnum.mustache | 12 ++++++ .../typescript/models/modelGeneric.mustache | 41 +++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index f5bbf2df97d1..f41e109fef6b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -10,9 +10,17 @@ export enum HttpMethod { PATCH = "PATCH" } +export interface FormEntry { + contentType: string; + value: string | Blob; +} + +export type FormData = { [key: string]: FormEntry }; + + export class Request { public headers: { [key: string]: string } = {}; - public body: string = ""; + public body: string | FormData = ""; public constructor(public url: string, public httpMethod: HttpMethod) { diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index 69aaffd071e6..25bef19fa9ef 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -7,9 +7,19 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: Request): Promise { let method = request.httpMethod.toString(); + let body: string | FormData = ""; + if (typeof request.body === "string") { + body = request.body; + } else { + body = new FormData(); + for (const key in request.body) { + body.append(key, request.body[key].value); + } + } + return fetch(request.url, { method: method, - body: request.body, + body: body, headers: request.headers, credentials: "same-origin" }).then((resp) => { @@ -23,5 +33,6 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { return new Response(resp.status, headers, body) }); }); + } } diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache new file mode 100644 index 000000000000..5fa32c28b882 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache @@ -0,0 +1,12 @@ +/** + * {{{description}}} + * @export + * @enum {string} + */ +export enum {{classname}} { +{{#allowableValues}} +{{#enumVars}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +} diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache new file mode 100644 index 000000000000..d4ba9f7b862c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache @@ -0,0 +1,41 @@ +/** + * {{{description}}} + * @export + * @interface {{classname}} + */ +export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#additionalPropertiesType}} + [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; + +{{/additionalPropertiesType}} +{{#vars}} + /** + * {{{description}}} + * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%> + * @memberof {{classname}} + */ + {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; +{{/vars}} +}{{#hasEnums}} + +/** + * @export + * @namespace {{classname}} + */ +export namespace {{classname}} { +{{#vars}} + {{#isEnum}} + /** + * @export + * @enum {string} + */ + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } + {{/isEnum}} +{{/vars}} +}{{/hasEnums}} From 6638cef37a9a859bec2bb418ac68052c1d138256 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 9 Aug 2018 21:02:43 +0200 Subject: [PATCH 03/85] Modified http lib, added config & middleware definition to ts-fetch --- .../ts-fetch-client/.openapi-generator-ignore | 23 ++++++++ .../.openapi-generator/VERSION | 1 + .../~/ts-fetch-client/README.md | 1 + .../~/ts-fetch-client/configuration.ts | 38 +++++++++++++ .../~/ts-fetch-client/http/http.ts | 51 +++++++++++++++++ .../ts-fetch-client/http/isomorphic-fetch.ts | 38 +++++++++++++ .../~/ts-fetch-client/middleware.ts | 6 ++ .../~/ts-fetch-client/package.json | 28 ++++++++++ .../~/ts-fetch-client/tsconfig.json | 29 ++++++++++ .../languages/TypeScriptClientCodegen.java | 6 ++ .../typescript/configuration.mustache | 41 ++++++++++++++ .../resources/typescript/http/http.mustache | 56 ++++++++++++++++--- .../typescript/http/isomorphic-fetch.mustache | 24 +++----- .../resources/typescript/middleware.mustache | 6 ++ .../resources/typescript/package.mustache | 9 ++- 15 files changed, 332 insertions(+), 25 deletions(-) create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/README.md create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/package.json create mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json create mode 100644 modules/openapi-generator/src/main/resources/typescript/configuration.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/middleware.mustache diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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 +# This 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 diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION new file mode 100644 index 000000000000..717311e32e3c --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/README.md b/modules/openapi-generator-cli/~/ts-fetch-client/README.md new file mode 100644 index 000000000000..ea786ff2cf69 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/README.md @@ -0,0 +1 @@ +readme \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts b/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts new file mode 100644 index 000000000000..06cc0f09bdd3 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts @@ -0,0 +1,38 @@ +import {HttpLibrary} from './http/http'; +import {Middleware} from './middleware'; + +export interface ConfigurationParameters { + basePath?: string; // override base path + httpApi?: HttpLibrary; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security +} + +export class Configuration { + + basePath: string; + httpApi: HttpLibrary; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + this.middleware = conf.middleware || []; + this.username = conf.username; + this.password = conf.password; + const { apiKey, accessToken } = conf; + if (apiKey) { + this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + } + if (accessToken) { + this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts b/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts new file mode 100644 index 000000000000..79391f8588c7 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts @@ -0,0 +1,51 @@ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +export interface FormEntry { + contentType: string; + value: string | Blob; +} + +export type FormData = { [key: string]: FormEntry }; + + +export class RequestContext { + public headers: { [key: string]: string } = {}; + public body: string | FormData = ""; + + public constructor(public url: string, public httpMethod: HttpMethod) { + + } + + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeader(key: string, value: string): void { + this.headers[key] = value; + } +} + +export class ResponseContext { + + public constructor(public httpStatusCode: number, + public headers: { [key: string]: string }, public body: string) { + } + +} + +export interface HttpLibrary { + send(request: RequestContext): Promise; +} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts b/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..47fb11c86e56 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts @@ -0,0 +1,38 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import * as e6p from 'es6-promise' +e6p.polyfill(); +import 'isomorphic-fetch'; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Promise { + let method = request.httpMethod.toString(); + let body: string | FormData = ""; + if (typeof request.body === "string") { + body = request.body; + } else { + body = new FormData(); + for (const key in request.body) { + body.append(key, request.body[key].value); + } + } + + return fetch(request.url, { + method: method, + body: body, + headers: request.headers, + credentials: "same-origin" + }).then((resp) => { + // hack + let headers = (resp.headers as any)._headers; + for (let key in headers) { + headers[key] = (headers[key] as Array).join("; "); + } + + return resp.text().then((body) => { + return new ResponseContext(resp.status, headers, body) + }); + }); + + } +} diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts b/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts new file mode 100644 index 000000000000..17fdcc8ea6f4 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts @@ -0,0 +1,6 @@ +import {RequestContext, ResponseContext} from './http/http'; + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/package.json b/modules/openapi-generator-cli/~/ts-fetch-client/package.json new file mode 100644 index 000000000000..4b73dd96ff24 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/package.json @@ -0,0 +1,28 @@ +{ + "name": "", + "version": "", + "description": "OpenAPI client for ", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator", + "" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "es6-promise": "^4.2.4", + "isomorphic-fetch": "^2.2.1", + "@types/isomorphic-fetch": "0.0.34" + }, + "devDependencies": { + "typescript": "^2.9.2" + } +} diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json b/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json new file mode 100644 index 000000000000..4ef0a0278025 --- /dev/null +++ b/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "module": "commonjs", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": true, /* Report errors on unused locals. */ + "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "declaration": true, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 76df02a6caed..d7e9613bf500 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -116,8 +116,14 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); + + // http supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts")); + + supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); + supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); + } diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache new file mode 100644 index 000000000000..2a7e7da234de --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -0,0 +1,41 @@ +import {HttpLibrary} from './http/http'; +import {Middleware} from './middleware'; +import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; + +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); + +export interface ConfigurationParameters { + basePath?: string; // override base path + httpApi?: HttpLibrary; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security +} + +export class Configuration { + + basePath: string; + httpApi: HttpLibrary; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? + this.middleware = conf.middleware || []; + this.username = conf.username; + this.password = conf.password; + const { apiKey, accessToken } = conf; + if (apiKey) { + this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + } + if (accessToken) { + this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index f41e109fef6b..4bd5bdcfefba 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -1,3 +1,6 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; + export enum HttpMethod { GET = "GET", HEAD = "HEAD", @@ -11,20 +14,57 @@ export enum HttpMethod { } export interface FormEntry { - contentType: string; + contentDisposition: string; value: string | Blob; } -export type FormData = { [key: string]: FormEntry }; +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} -export class Request { - public headers: { [key: string]: string } = {}; - public body: string | FormData = ""; +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: string | FormData = ""; - public constructor(public url: string, public httpMethod: HttpMethod) { + public constructor(private url: string, private httpMethod: HttpMethod) { } + + public getUrl(): string { + return this.url; + } + + public setUrl(url: string) { + this.url = url; + } + + public setBody(body: string | FormData) { + // HTTP-Spec 1.1 Section 4.3 + if (this.httpMethod === HttpMethod.GET) { + throw new HttpException("Body should not be included in GET-Requests!"); + } + + // TODO: other http methods + + // post is fine either formData or string + this.body = body; + + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): string | FormData { + return this.body; + } public addCookie(name: string, value: string): void { if (!this.headers["Cookie"]) { @@ -38,7 +78,7 @@ export class Request { } } -export class Response { +export class ResponseContext { public constructor(public httpStatusCode: number, public headers: { [key: string]: string }, public body: string) { @@ -47,5 +87,5 @@ export class Response { } export interface HttpLibrary { - send(request: Request): Promise; + send(request: RequestContext): Promise; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index 25bef19fa9ef..dd200043238c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,26 +1,18 @@ -import {HttpLibrary, Request, Response} from './http'; +import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' e6p.polyfill(); import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { - public send(request: Request): Promise { - let method = request.httpMethod.toString(); - let body: string | FormData = ""; - if (typeof request.body === "string") { - body = request.body; - } else { - body = new FormData(); - for (const key in request.body) { - body.append(key, request.body[key].value); - } - } + public send(request: RequestContext): Promise { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); - return fetch(request.url, { + return fetch(request.getUrl(), { method: method, - body: body, - headers: request.headers, + body: body as any, + headers: request.getHeaders(), credentials: "same-origin" }).then((resp) => { // hack @@ -30,7 +22,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { } return resp.text().then((body) => { - return new Response(resp.status, headers, body) + return new ResponseContext(resp.status, headers, body) }); }); diff --git a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache new file mode 100644 index 000000000000..17fdcc8ea6f4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache @@ -0,0 +1,6 @@ +import {RequestContext, ResponseContext} from './http/http'; + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 327f133bcebc..cb3ab771c690 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -21,9 +21,16 @@ "es6-promise": "^4.2.4", "isomorphic-fetch": "^2.2.1", "@types/isomorphic-fetch": "0.0.34" + "form-data": "^2.3.2", + "@types/form-data": "^2.2.1", }, "devDependencies": { - "typescript": "^2.9.2" + "ts-node": "^7.0.0", + "typescript": "^2.9.2", + "@types/chai": "^4.1.4", + "@types/mocha": "^5.2.5", + "chai": "^4.1.2", + "mocha": "^5.2.0" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig":{ From 1a31c48ceb6c819e25e99139e33f2ae2cd3dc698 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 9 Aug 2018 21:40:47 +0200 Subject: [PATCH 04/85] Added model generation with imports --- .../languages/TypeScriptClientCodegen.java | 3 +++ .../resources/typescript/licenseInfo.mustache | 3 +++ .../resources/typescript/models/models.mustache | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/models/models.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index d7e9613bf500..b9913272c08e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -124,6 +124,9 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); + // models + this.modelPackage = ""; + this.modelTemplateFiles.put("models/models.mustache", ".ts"); } diff --git a/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache new file mode 100644 index 000000000000..e4d6f0225775 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache @@ -0,0 +1,3 @@ +/* + TODO: LICENSE INFO +*/ \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/models/models.mustache b/modules/openapi-generator/src/main/resources/typescript/models/models.mustache new file mode 100644 index 000000000000..0eebdc9ceb78 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/models/models.mustache @@ -0,0 +1,15 @@ +// tslint:disable +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#imports}} +import { {{.}} } from './{{.}}'; +{{/imports}} +{{#isEnum}} +{{>models/modelEnum}} +{{/isEnum}} +{{^isEnum}} +{{>models/modelGeneric}} +{{/isEnum}} +{{/model}} +{{/models}} \ No newline at end of file From 1cc6fb0421e13ecaef788d95f993a3980ff96071 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 12 Aug 2018 15:33:22 +0200 Subject: [PATCH 05/85] Added auth module --- .../languages/TypeScriptClientCodegen.java | 3 +- .../resources/typescript/auth/auth.mustache | 62 +++++++++++++++++++ .../resources/typescript/http/http.mustache | 23 +++++-- .../resources/typescript/package.mustache | 4 +- 4 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index b9913272c08e..20bb097eaea7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -123,7 +123,8 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); - + supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); + // models this.modelPackage = ""; this.modelTemplateFiles.put("models/models.mustache", ".ts"); diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache new file mode 100644 index 000000000000..7d88980180e0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -0,0 +1,62 @@ +import {RequestContext} from '../http/http'; +// typings for btoa are incorrect +//@ts-ignore +import * as btoa from "btoa"; + +export abstract class SecurityAuthentication { + + public constructor(private name: string) { + + } + + /* + * + * @return returns the name of the security authentication as specified in OAI + */ + public getName(): string { + return this.name; + } + + public abstract applySecurityAuthentication(context: RequestContext): void; + +} + +export class NoAuthentication extends SecurityAuthentication { + + public constructor() { + super("_no_auth"); + } + + public applySecurityAuthentication(_context: RequestContext) { + + } +} + +export class APIKeyAuthentication extends SecurityAuthentication { + + public constructor(authName: string, private paramName: string, private apiKey: string, private keyLocation: "query" | "header" | "cookie") { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + if (this.keyLocation === "header") { + context.setHeaderParam(this.paramName, this.apiKey); + } else if (this.keyLocation === "cookie") { + context.addCookie(this.paramName, this.apiKey); + } else if (this.keyLocation === "query") { + context.setQueryParam(this.paramName, this.apiKey); + } + } +} + +export class HttpBasicAuthentication extends SecurityAuthentication { + + public constructor(authName: string, private username: string, private password: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + let comb = this.username + ":" + this.password; + context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 4bd5bdcfefba..e23d864203cb 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -1,5 +1,8 @@ // TODO: evaluate if we can easily get rid of this library import * as FormData from "form-data"; +// typings of url-parse are incorrect... +// @ts-ignore +import * as URLParse from "url-parse"; export enum HttpMethod { GET = "GET", @@ -28,18 +31,20 @@ export class HttpException extends Error { export class RequestContext { private headers: { [key: string]: string } = {}; private body: string | FormData = ""; - - public constructor(private url: string, private httpMethod: HttpMethod) { - + private url: URLParse; + + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = URLParse(url, true); } public getUrl(): string { - return this.url; + return this.url.toString(); } public setUrl(url: string) { - this.url = url; + this.url = URLParse(url, true); } + public setBody(body: string | FormData) { // HTTP-Spec 1.1 Section 4.3 @@ -66,6 +71,12 @@ export class RequestContext { return this.body; } + public setQueryParam(name: string, value: string) { + let queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + } + public addCookie(name: string, value: string): void { if (!this.headers["Cookie"]) { this.headers["Cookie"] = ""; @@ -73,7 +84,7 @@ export class RequestContext { this.headers["Cookie"] += name + "=" + value + "; "; } - public setHeader(key: string, value: string): void { + public setHeaderParam(key: string, value: string): void { this.headers[key] = value; } } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index cb3ab771c690..08be2ff1f3fb 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -20,9 +20,11 @@ "dependencies": { "es6-promise": "^4.2.4", "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34" + "btoa": "^1.2.1", + "@types/isomorphic-fetch": "0.0.34", "form-data": "^2.3.2", "@types/form-data": "^2.2.1", + "url-parse": "^1.4.3" }, "devDependencies": { "ts-node": "^7.0.0", From 276d7d47e57cb75786d33b55b07c5e44b3c8d95c Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 13 Aug 2018 21:18:51 +0200 Subject: [PATCH 06/85] Added servers --- .../languages/TypeScriptClientCodegen.java | 2 +- .../typescript/configuration.mustache | 9 ++++----- .../resources/typescript/servers.mustache | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/servers.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 20bb097eaea7..ad1ad80ad1bc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -124,7 +124,7 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); - + supportingFiles.add(new SupportingFile("servers.mustache", "servers.ts")); // models this.modelPackage = ""; this.modelTemplateFiles.put("models/models.mustache", ".ts"); diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 2a7e7da234de..59f971410751 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,11 +1,10 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; - -export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); +import {ServerConfiguration, servers} from './servers'; export interface ConfigurationParameters { - basePath?: string; // override base path + baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests username?: string; // parameter for basic security @@ -16,7 +15,7 @@ export interface ConfigurationParameters { export class Configuration { - basePath: string; + baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; username?: string; @@ -25,7 +24,7 @@ export class Configuration { accessToken?: (name: string, scopes?: string[]) => string; constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; this.username = conf.username; diff --git a/modules/openapi-generator/src/main/resources/typescript/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/servers.mustache new file mode 100644 index 000000000000..6d738c290966 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/servers.mustache @@ -0,0 +1,19 @@ +import {RequestContext, HttpMethod} from './http/http'; + +export class ServerConfiguration { + + public constructor(private url: string) { + } + + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.url + endpoint, httpMethod); + } +} + +{{#openAPI}} +export const servers = [ + {{#servers}} + new ServerConfiguration("{{url}}"){{^last}},{{/last}} + {{/servers}} +] +{{/openAPI}} \ No newline at end of file From b89646a223f025ec615d8985b259df257b042fc1 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 13 Aug 2018 22:17:35 +0200 Subject: [PATCH 07/85] Added sample for typescript client --- bin/typescript.sh | 32 + .../languages/TypeScriptClientCodegen.java | 2 + .../main/resources/typescript/index.mustache | 9 + .../resources/typescript/middleware.mustache | 4 +- .../resources/typescript/package.mustache | 4 +- .../builds/default/.openapi-generator-ignore | 23 + .../builds/default/.openapi-generator/VERSION | 1 + .../typescript/builds/default/README.md | 1 + .../typescript/builds/default/auth/auth.ts | 62 ++ .../builds/default/configuration.ts | 40 + .../typescript/builds/default/http/http.ts | 102 ++ .../builds/default/http/isomorphic-fetch.ts | 30 + .../typescript/builds/default/index.ts | 9 + .../typescript/builds/default/middleware.ts | 8 + .../builds/default/models/ApiResponse.ts | 30 + .../builds/default/models/Category.ts | 24 + .../typescript/builds/default/models/Order.ts | 64 ++ .../typescript/builds/default/models/Pet.ts | 66 ++ .../typescript/builds/default/models/Tag.ts | 24 + .../typescript/builds/default/models/User.ts | 60 ++ .../builds/default/package-lock.json | 468 +++++++++ .../typescript/builds/default/package.json | 37 + .../typescript/builds/default/servers.ts | 15 + .../typescript/builds/default/tsconfig.json | 29 + .../tests/default/dist/auth/auth.test.js | 46 + .../dist/http/isomorphic-fetch.test.js | 65 ++ .../tests/default/package-lock.json | 977 ++++++++++++++++++ .../typescript/tests/default/package.json | 32 + .../petstore/typescript/tests/default/pom.xml | 59 ++ .../tests/default/test/auth/auth.test.ts | 55 + .../test/http/isomorphic-fetch.test.ts | 68 ++ .../typescript/tests/default/tsconfig.json | 19 + 32 files changed, 2462 insertions(+), 3 deletions(-) create mode 100755 bin/typescript.sh create mode 100644 modules/openapi-generator/src/main/resources/typescript/index.mustache create mode 100644 samples/client/petstore/typescript/builds/default/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript/builds/default/README.md create mode 100644 samples/client/petstore/typescript/builds/default/auth/auth.ts create mode 100644 samples/client/petstore/typescript/builds/default/configuration.ts create mode 100644 samples/client/petstore/typescript/builds/default/http/http.ts create mode 100644 samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts create mode 100644 samples/client/petstore/typescript/builds/default/index.ts create mode 100644 samples/client/petstore/typescript/builds/default/middleware.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Category.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Order.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Pet.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Tag.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/User.ts create mode 100644 samples/client/petstore/typescript/builds/default/package-lock.json create mode 100644 samples/client/petstore/typescript/builds/default/package.json create mode 100644 samples/client/petstore/typescript/builds/default/servers.ts create mode 100644 samples/client/petstore/typescript/builds/default/tsconfig.json create mode 100644 samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js create mode 100644 samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js create mode 100644 samples/client/petstore/typescript/tests/default/package-lock.json create mode 100644 samples/client/petstore/typescript/tests/default/package.json create mode 100644 samples/client/petstore/typescript/tests/default/pom.xml create mode 100644 samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts create mode 100644 samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts create mode 100644 samples/client/petstore/typescript/tests/default/tsconfig.json diff --git a/bin/typescript.sh b/bin/typescript.sh new file mode 100755 index 000000000000..78e2ab585eb3 --- /dev/null +++ b/bin/typescript.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn -B clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index ad1ad80ad1bc..99e8893a74a1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -125,6 +125,8 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); supportingFiles.add(new SupportingFile("servers.mustache", "servers.ts")); + supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); + // models this.modelPackage = ""; this.modelTemplateFiles.put("models/models.mustache", ".ts"); diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache new file mode 100644 index 000000000000..507c0bf9283d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -0,0 +1,9 @@ +export * from './configuration' +export * from './http/http'; +export * from './auth/auth'; +export * from './middleware'; +export * from './servers'; +// TODO: export models, export API + +// TODO: make this export conditional => only if isomorphic-fetch is included +export * from './http/isomorphic-fetch'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache index 17fdcc8ea6f4..782cddb321c9 100644 --- a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache @@ -3,4 +3,6 @@ import {RequestContext, ResponseContext} from './http/http'; export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; -} \ No newline at end of file +} + +// TODO: package.json set npmName \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 08be2ff1f3fb..7fe4daed3e96 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -1,6 +1,6 @@ { - "name": "{{npmName}}", - "version": "{{npmVersion}}", + "name": "ts-petstore-client", + "version": "1.0.0", "description": "OpenAPI client for {{npmName}}", "author": "OpenAPI-Generator Contributors", "keywords": [ diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator-ignore b/samples/client/petstore/typescript/builds/default/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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 +# This 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 diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION new file mode 100644 index 000000000000..717311e32e3c --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/README.md b/samples/client/petstore/typescript/builds/default/README.md new file mode 100644 index 000000000000..ea786ff2cf69 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/README.md @@ -0,0 +1 @@ +readme \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/client/petstore/typescript/builds/default/auth/auth.ts new file mode 100644 index 000000000000..7d88980180e0 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/auth/auth.ts @@ -0,0 +1,62 @@ +import {RequestContext} from '../http/http'; +// typings for btoa are incorrect +//@ts-ignore +import * as btoa from "btoa"; + +export abstract class SecurityAuthentication { + + public constructor(private name: string) { + + } + + /* + * + * @return returns the name of the security authentication as specified in OAI + */ + public getName(): string { + return this.name; + } + + public abstract applySecurityAuthentication(context: RequestContext): void; + +} + +export class NoAuthentication extends SecurityAuthentication { + + public constructor() { + super("_no_auth"); + } + + public applySecurityAuthentication(_context: RequestContext) { + + } +} + +export class APIKeyAuthentication extends SecurityAuthentication { + + public constructor(authName: string, private paramName: string, private apiKey: string, private keyLocation: "query" | "header" | "cookie") { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + if (this.keyLocation === "header") { + context.setHeaderParam(this.paramName, this.apiKey); + } else if (this.keyLocation === "cookie") { + context.addCookie(this.paramName, this.apiKey); + } else if (this.keyLocation === "query") { + context.setQueryParam(this.paramName, this.apiKey); + } + } +} + +export class HttpBasicAuthentication extends SecurityAuthentication { + + public constructor(authName: string, private username: string, private password: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + let comb = this.username + ":" + this.password; + context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts new file mode 100644 index 000000000000..59f971410751 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -0,0 +1,40 @@ +import {HttpLibrary} from './http/http'; +import {Middleware} from './middleware'; +import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; +import {ServerConfiguration, servers} from './servers'; + +export interface ConfigurationParameters { + baseServer?: ServerConfiguration; + httpApi?: HttpLibrary; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security +} + +export class Configuration { + + baseServer: ServerConfiguration; + httpApi: HttpLibrary; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; + this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? + this.middleware = conf.middleware || []; + this.username = conf.username; + this.password = conf.password; + const { apiKey, accessToken } = conf; + if (apiKey) { + this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + } + if (accessToken) { + this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts new file mode 100644 index 000000000000..e23d864203cb --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -0,0 +1,102 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; +// typings of url-parse are incorrect... +// @ts-ignore +import * as URLParse from "url-parse"; + +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +export interface FormEntry { + contentDisposition: string; + value: string | Blob; +} + + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: string | FormData = ""; + private url: URLParse; + + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = URLParse(url, true); + } + + public getUrl(): string { + return this.url.toString(); + } + + public setUrl(url: string) { + this.url = URLParse(url, true); + } + + + public setBody(body: string | FormData) { + // HTTP-Spec 1.1 Section 4.3 + if (this.httpMethod === HttpMethod.GET) { + throw new HttpException("Body should not be included in GET-Requests!"); + } + + // TODO: other http methods + + // post is fine either formData or string + this.body = body; + + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): string | FormData { + return this.body; + } + + public setQueryParam(name: string, value: string) { + let queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + } + + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } +} + +export class ResponseContext { + + public constructor(public httpStatusCode: number, + public headers: { [key: string]: string }, public body: string) { + } + +} + +export interface HttpLibrary { + send(request: RequestContext): Promise; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..dd200043238c --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -0,0 +1,30 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import * as e6p from 'es6-promise' +e6p.polyfill(); +import 'isomorphic-fetch'; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Promise { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + return fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + credentials: "same-origin" + }).then((resp) => { + // hack + let headers = (resp.headers as any)._headers; + for (let key in headers) { + headers[key] = (headers[key] as Array).join("; "); + } + + return resp.text().then((body) => { + return new ResponseContext(resp.status, headers, body) + }); + }); + + } +} diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts new file mode 100644 index 000000000000..507c0bf9283d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -0,0 +1,9 @@ +export * from './configuration' +export * from './http/http'; +export * from './auth/auth'; +export * from './middleware'; +export * from './servers'; +// TODO: export models, export API + +// TODO: make this export conditional => only if isomorphic-fetch is included +export * from './http/isomorphic-fetch'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts new file mode 100644 index 000000000000..782cddb321c9 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -0,0 +1,8 @@ +import {RequestContext, ResponseContext} from './http/http'; + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} + +// TODO: package.json set npmName \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts new file mode 100644 index 000000000000..45f839a03ab9 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -0,0 +1,30 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ +export interface ApiResponse { + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts new file mode 100644 index 000000000000..c950f45dfcc1 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts new file mode 100644 index 000000000000..d2699e865ee9 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -0,0 +1,64 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {Date} + * @memberof Order + */ + shipDate?: Date; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: Order.StatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @namespace Order + */ +export namespace Order { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts new file mode 100644 index 000000000000..529d264a31e2 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -0,0 +1,66 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +import { Category } from './Category'; +import { Tag } from './Tag'; +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: Pet.StatusEnum; +} + +/** + * @export + * @namespace Pet + */ +export namespace Pet { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts new file mode 100644 index 000000000000..eb777b1c6163 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts new file mode 100644 index 000000000000..247a8665e8b3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -0,0 +1,60 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} + diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json new file mode 100644 index 000000000000..c1d83a3dec01 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -0,0 +1,468 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", + "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", + "dev": true + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" + }, + "@types/mocha": { + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", + "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", + "dev": true + }, + "@types/node": { + "version": "10.5.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz", + "integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ==" + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "dev": true, + "requires": { + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "es6-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "make-error": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", + "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==", + "dev": true + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "querystringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", + "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz", + "integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "ts-node": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "url-parse": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", + "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", + "requires": { + "querystringify": "^2.0.0", + "requires-port": "^1.0.0" + } + }, + "whatwg-fetch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", + "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", + "dev": true + } + } +} diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json new file mode 100644 index 000000000000..e09caae835ad --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -0,0 +1,37 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "description": "OpenAPI client for ", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator", + "" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "es6-promise": "^4.2.4", + "isomorphic-fetch": "^2.2.1", + "btoa": "^1.2.1", + "@types/isomorphic-fetch": "0.0.34", + "form-data": "^2.3.2", + "@types/form-data": "^2.2.1", + "url-parse": "^1.4.3" + }, + "devDependencies": { + "ts-node": "^7.0.0", + "typescript": "^2.9.2", + "@types/chai": "^4.1.4", + "@types/mocha": "^5.2.5", + "chai": "^4.1.2", + "mocha": "^5.2.0" + } +} diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts new file mode 100644 index 000000000000..7cc55b40db0c --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -0,0 +1,15 @@ +import {RequestContext, HttpMethod} from './http/http'; + +export class ServerConfiguration { + + public constructor(private url: string) { + } + + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.url + endpoint, httpMethod); + } +} + +export const servers = [ + new ServerConfiguration("http://petstore.swagger.io/v2"), +] diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json new file mode 100644 index 000000000000..4ef0a0278025 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "module": "commonjs", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": true, /* Report errors on unused locals. */ + "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "declaration": true, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js new file mode 100644 index 000000000000..6cf65e3d7acf --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var ts_petstore_client_2 = require("ts-petstore-client"); +var chai_1 = require("chai"); +describe("Security Authentication", function () { + describe("No Authentication", function () { + it("No Authentication", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var noAuth = new ts_petstore_client_1.NoAuthentication(); + noAuth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.deep.equal({}); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + }); + describe("API Key Authentication", function () { + // TODO: make all params const variables + it("Header API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "header"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); + chai_1.expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + it("Query API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "query"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); + chai_1.expect(ctx.getHeaders()).to.deep.equal({}); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + it("Cookie API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "cookie"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); + chai_1.expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + }); +}); diff --git a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js new file mode 100644 index 000000000000..ffb7c282e4e4 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js @@ -0,0 +1,65 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var ts_petstore_client_2 = require("ts-petstore-client"); +var chai_1 = require("chai"); +var FormData = require("form-data"); +var libs = { + "isomorphic-fetch": new ts_petstore_client_2.IsomorphicFetchHttpLibrary() +}; +var _loop_1 = function (libName) { + var lib = libs[libName]; + describe("Isomorphic Fetch", function () { + it("GET-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/get", ts_petstore_client_1.HttpMethod.GET); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["headers"]).to.exist; + chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + done(); + }).catch(function (e) { + done(e); + }); + }); + it("POST-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/post", ts_petstore_client_1.HttpMethod.POST); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + var formData = new FormData(); + formData.append("test", "test2"); + formData.append("testFile", Buffer.from("abc"), "fileName.json"); + requestContext.setBody(formData); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["headers"]).to.exist; + chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + chai_1.expect(body["files"]["testFile"]).to.equal("abc"); + chai_1.expect(body["form"]["test"]).to.equal("test2"); + done(); + }).catch(function (e) { + done(e); + }); + }); + it("Cookies-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/cookies", ts_petstore_client_1.HttpMethod.GET); + requestContext.addCookie("test-cookie", "cookie-value"); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); + done(); + }).catch(function (e) { + done(e); + }); + }); + }); +}; +for (var libName in libs) { + _loop_1(libName); +} diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json new file mode 100644 index 000000000000..2cdcc84cc4aa --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -0,0 +1,977 @@ +{ + "name": "typescript-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", + "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", + "dev": true + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + }, + "dependencies": { + "@types/node": { + "version": "10.5.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz", + "integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ==" + } + } + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=", + "dev": true + }, + "@types/mocha": { + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", + "dev": true + }, + "@types/node": { + "version": "8.10.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.25.tgz", + "integrity": "sha512-WXvAXaknB0c2cJ7N44e1kUrVu5K90mSfPPaT5XxfuSMxEWva86EYIwxUZM3jNZ2P1CIC9e2z4WJqpAF69PQxeA==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "big.js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "dev": true, + "requires": { + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "color-convert": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "requires": { + "color-name": "1.1.1" + } + }, + "color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=" + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "enhanced-resolve": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", + "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "object-assign": "^4.0.1", + "tapable": "^0.2.7" + } + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "dev": true, + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "make-error": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", + "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==" + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "requires": { + "source-map": "^0.5.6" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tapable": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", + "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", + "dev": true + }, + "ts-loader": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.7.tgz", + "integrity": "sha512-8t3bu2FcEkXb+D4L+Cn8qiK2E2C6Ms4/GQChvz6IMbVurcFHLXrhW4EMtfaol1a1ASQACZGDUGit4NHnX9g7hQ==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "enhanced-resolve": "^3.0.0", + "loader-utils": "^1.0.2", + "semver": "^5.0.1" + } + }, + "ts-node": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", + "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", + "requires": { + "arrify": "^1.0.0", + "chalk": "^2.0.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.0", + "tsconfig": "^6.0.0", + "v8flags": "^3.0.0", + "yn": "^2.0.0" + } + }, + "ts-petstore-client": { + "version": "file:../../builds/default", + "requires": { + "@types/form-data": "^2.2.1", + "@types/isomorphic-fetch": "0.0.34", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", + "form-data": "^2.3.2", + "isomorphic-fetch": "^2.2.1", + "url-parse": "^1.4.3" + }, + "dependencies": { + "@types/chai": { + "version": "4.1.4", + "bundled": true + }, + "@types/form-data": { + "version": "2.2.1", + "bundled": true, + "requires": { + "@types/node": "*" + } + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "bundled": true + }, + "@types/mocha": { + "version": "5.2.5", + "bundled": true + }, + "@types/node": { + "version": "10.5.8", + "bundled": true + }, + "arrify": { + "version": "1.0.1", + "bundled": true + }, + "assertion-error": { + "version": "1.1.0", + "bundled": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "bundled": true + }, + "btoa": { + "version": "1.2.1", + "bundled": true + }, + "buffer-from": { + "version": "1.1.1", + "bundled": true + }, + "chai": { + "version": "4.1.2", + "bundled": true, + "requires": { + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" + } + }, + "check-error": { + "version": "1.0.2", + "bundled": true + }, + "combined-stream": { + "version": "1.0.6", + "bundled": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "bundled": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "debug": { + "version": "3.1.0", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "bundled": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "diff": { + "version": "3.5.0", + "bundled": true + }, + "encoding": { + "version": "0.1.12", + "bundled": true, + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "es6-promise": { + "version": "4.2.4", + "bundled": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "bundled": true + }, + "form-data": { + "version": "2.3.2", + "bundled": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "get-func-name": { + "version": "2.0.0", + "bundled": true + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "bundled": true + }, + "has-flag": { + "version": "3.0.0", + "bundled": true + }, + "he": { + "version": "1.1.1", + "bundled": true + }, + "iconv-lite": { + "version": "0.4.23", + "bundled": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "is-stream": { + "version": "1.1.0", + "bundled": true + }, + "isomorphic-fetch": { + "version": "2.2.1", + "bundled": true, + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "make-error": { + "version": "1.3.4", + "bundled": true + }, + "mime-db": { + "version": "1.35.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.19", + "bundled": true, + "requires": { + "mime-db": "~1.35.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "bundled": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "node-fetch": { + "version": "1.7.3", + "bundled": true, + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "pathval": { + "version": "1.1.0", + "bundled": true + }, + "querystringify": { + "version": "2.0.0", + "bundled": true + }, + "requires-port": { + "version": "1.0.0", + "bundled": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true + }, + "source-map": { + "version": "0.6.1", + "bundled": true + }, + "source-map-support": { + "version": "0.5.8", + "bundled": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "supports-color": { + "version": "5.4.0", + "bundled": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "ts-node": { + "version": "7.0.1", + "bundled": true, + "requires": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true + } + } + }, + "type-detect": { + "version": "4.0.8", + "bundled": true + }, + "typescript": { + "version": "2.9.2", + "bundled": true + }, + "url-parse": { + "version": "1.4.3", + "bundled": true, + "requires": { + "querystringify": "^2.0.0", + "requires-port": "^1.0.0" + } + }, + "whatwg-fetch": { + "version": "2.0.4", + "bundled": true + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + }, + "yn": { + "version": "2.0.0", + "bundled": true + } + } + }, + "tsconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", + "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", + "requires": { + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "v8flags": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", + "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=" + } + } +} diff --git a/samples/client/petstore/typescript/tests/default/package.json b/samples/client/petstore/typescript/tests/default/package.json new file mode 100644 index 000000000000..32c3c525b210 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/package.json @@ -0,0 +1,32 @@ +{ + "private": true, + "dependencies": { + "@types/form-data": "^2.2.1", + "form-data": "^2.3.2", + "ts-node": "^3.3.0", + "ts-petstore-client": "file:../../builds/default" + }, + "scripts": { + "prepublish": "npm install ../../builds/default && npm run build", + "test": "mocha test/**/*.ts -r ts-node/register --timeout 10000", + "build": "tsc" + }, + "devDependencies": { + "@types/chai": "^4.0.1", + "chai": "^4.1.0", + "@types/isomorphic-fetch": "0.0.34", + "@types/mocha": "^2.2.41", + "@types/node": "^8.0.14", + "mocha": "^5.2.0", + "ts-loader": "^2.3.0", + "typescript": "^2.4.1" + }, + "name": "typescript-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/client/petstore/typescript/tests/default/pom.xml b/samples/client/petstore/typescript/tests/default/pom.xml new file mode 100644 index 000000000000..d9f5844d4fcb --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + com.wordnik + TypeScriptClientTest + pom + 1.0-SNAPSHOT + TS Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts new file mode 100644 index 000000000000..c7aa44e6235b --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -0,0 +1,55 @@ +import {NoAuthentication, APIKeyAuthentication} from "ts-petstore-client"; +import {RequestContext, HttpMethod} from 'ts-petstore-client'; +import { expect} from "chai"; + + + +describe("Security Authentication", () => { + describe("No Authentication", () => { + it("No Authentication", () => { + let ctx = new RequestContext("http://google.com", HttpMethod.GET); + let noAuth = new NoAuthentication(); + noAuth.applySecurityAuthentication(ctx); + + expect(ctx.getUrl()).to.equal("http://google.com"); + expect(ctx.getHeaders()).to.deep.equal({}); + expect(ctx.getBody()).to.equal(""); + }); + }) + + describe("API Key Authentication", () => { + // TODO: make all params const variables + it("Header API Key", () => { + let ctx = new RequestContext("http://google.com", HttpMethod.GET); + let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "header"); + auth.applySecurityAuthentication(ctx); + + expect(ctx.getUrl()).to.equal("http://google.com"); + expect(ctx.getHeaders()).to.have.property("paramName"); + expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); + expect(ctx.getBody()).to.equal(""); + }); + + it("Query API Key", () => { + let ctx = new RequestContext("http://google.com?a=b", HttpMethod.GET); + let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "query"); + auth.applySecurityAuthentication(ctx); + + expect(ctx.getUrl()).to.contain("paramName=apiKey"); + expect(ctx.getHeaders()).to.deep.equal({}); + expect(ctx.getBody()).to.equal(""); + }); + + it("Cookie API Key", () => { + let ctx = new RequestContext("http://google.com", HttpMethod.GET); + let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "cookie"); + auth.applySecurityAuthentication(ctx); + + expect(ctx.getUrl()).to.equal("http://google.com"); + expect(ctx.getHeaders()).to.have.property("Cookie"); + expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); + expect(ctx.getBody()).to.equal(""); + }); + + }) +}); \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts new file mode 100644 index 000000000000..f6c6230ff603 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -0,0 +1,68 @@ +import {RequestContext, HttpMethod, ResponseContext, HttpLibrary} from "ts-petstore-client"; +import {IsomorphicFetchHttpLibrary} from 'ts-petstore-client'; +import { expect} from "chai"; +import * as FormData from "form-data"; + +let libs: { [key: string]: HttpLibrary } = { + "isomorphic-fetch": new IsomorphicFetchHttpLibrary() +} + + +for (let libName in libs) { + let lib = libs[libName]; + + describe("Isomorphic Fetch", () => { + it("GET-Request", (done) => { + let requestContext = new RequestContext("http://httpbin.org/get", HttpMethod.GET); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + lib.send(requestContext).then((resp: ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["headers"]).to.exist; + expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + done(); + }).catch((e) => { + done(e); + }) + }) + + it("POST-Request", (done) => { + let requestContext = new RequestContext("http://httpbin.org/post", HttpMethod.POST); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + let formData: FormData = new FormData() + formData.append("test", "test2"); + formData.append("testFile", Buffer.from("abc"), "fileName.json"); + + requestContext.setBody(formData); + lib.send(requestContext).then((resp: ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["headers"]).to.exist; + expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + expect(body["files"]["testFile"]).to.equal("abc"); + expect(body["form"]["test"]).to.equal("test2"); + done(); + }).catch((e) => { + done(e); + }) + }); + + it("Cookies-Request", (done) => { + let requestContext = new RequestContext("http://httpbin.org/cookies", HttpMethod.GET); + requestContext.addCookie("test-cookie", "cookie-value"); + + lib.send(requestContext).then((resp: ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); + done(); + }).catch((e) => { + done(e); + }) + }) + }) +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/client/petstore/typescript/tests/default/tsconfig.json new file mode 100644 index 000000000000..6524f781742b --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} From 6b2a2289f28b34c0f210e175d072751175017d31 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Tue, 14 Aug 2018 19:38:00 +0200 Subject: [PATCH 08/85] WIP: Models & API --- .../languages/TypeScriptClientCodegen.java | 34 ++++- .../main/resources/typescript/api.mustache | 41 ++++++ .../resources/typescript/baseapi.mustache | 37 +++++ .../typescript/configuration.mustache | 1 + .../{models => }/modelEnum.mustache | 0 .../{models => }/modelGeneric.mustache | 0 .../typescript/{models => }/models.mustache | 4 +- .../typescript/builds/default/apis/PetApi.ts | 134 ++++++++++++++++++ .../builds/default/apis/StoreApi.ts | 71 ++++++++++ .../typescript/builds/default/apis/UserApi.ts | 129 +++++++++++++++++ .../builds/default/apis/apis/PetApi.ts | 96 +++++++++++++ .../builds/default/apis/apis/StoreApi.ts | 49 +++++++ .../builds/default/apis/apis/UserApi.ts | 91 ++++++++++++ .../typescript/builds/default/apis/baseapi.ts | 37 +++++ .../default/models/models/ApiResponse.ts | 30 ++++ .../builds/default/models/models/Category.ts | 24 ++++ .../builds/default/models/models/Order.ts | 64 +++++++++ .../builds/default/models/models/Pet.ts | 66 +++++++++ .../builds/default/models/models/Tag.ts | 24 ++++ .../builds/default/models/models/User.ts | 60 ++++++++ 20 files changed, 987 insertions(+), 5 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/api.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/baseapi.mustache rename modules/openapi-generator/src/main/resources/typescript/{models => }/modelEnum.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{models => }/modelGeneric.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{models => }/models.mustache (79%) create mode 100644 samples/client/petstore/typescript/builds/default/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/baseapi.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Category.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Order.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Pet.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Tag.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/User.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 99e8893a74a1..0408e69b81d3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -17,10 +17,13 @@ package org.openapitools.codegen.languages; +import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.NumberSchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.security.SecurityScheme; + import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; @@ -29,6 +32,7 @@ import java.io.File; import java.util.*; +import java.util.Map.Entry; public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptClientCodegen.class); @@ -128,8 +132,13 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); // models - this.modelPackage = ""; - this.modelTemplateFiles.put("models/models.mustache", ".ts"); + this.setModelPackage(""); + this.modelTemplateFiles.put("models.mustache", ".ts"); + + // api + this.setApiPackage(""); + this.supportingFiles.add(new SupportingFile("baseapi.mustache", "apis", "baseapi.ts")); + this.apiTemplateFiles.put("api.mustache", ".ts"); } @@ -137,7 +146,26 @@ public TypeScriptClientCodegen() { public CodegenType getTag() { return CodegenType.CLIENT; } - + + @Override + public Map postProcessOperations(Map operations) { + Map objs = (Map) operations.get("operations"); + + + // Add additional filename information for model imports in the apis + List> imports = (List>) operations.get("imports"); + for (Map im : imports) { + im.put("filename", ((String) im.get("import")).replace('.', '/')); + im.put("classname", getModelnameFromModelFilename(im.get("import").toString())); + } + return operations; + } + + private String getModelnameFromModelFilename(String filename) { + String name = filename.substring((modelPackage() + File.separator).length()); + return camelize(name); + } + @Override public String escapeReservedWord(String name) { if (this.reservedWordsMappings().containsKey(name)) { diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api.mustache new file mode 100644 index 000000000000..3dd5268a4b17 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/api.mustache @@ -0,0 +1,41 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +{{#imports}} +import { {{classname}} } from '..{{filename}}'; +{{/imports}} + + + +{{#operations}} + +/** + * {{classname}} - interface{{#description}} + * {{&description}}{{/description}} + * @export + * @interface {{classname}} + */ +export class {{classname}}RequestFactory { + + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof {{classname}}Interface + */ + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { + + + return null; + } + + {{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache b/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache new file mode 100644 index 000000000000..fe7ee3d15118 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 59f971410751..a9a25e5952d9 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -7,6 +7,7 @@ export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache rename to modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache rename to modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/models/models.mustache b/modules/openapi-generator/src/main/resources/typescript/models.mustache similarity index 79% rename from modules/openapi-generator/src/main/resources/typescript/models/models.mustache rename to modules/openapi-generator/src/main/resources/typescript/models.mustache index 0eebdc9ceb78..b39583e15a49 100644 --- a/modules/openapi-generator/src/main/resources/typescript/models/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/models.mustache @@ -6,10 +6,10 @@ import { {{.}} } from './{{.}}'; {{/imports}} {{#isEnum}} -{{>models/modelEnum}} +{{>modelEnum}} {{/isEnum}} {{^isEnum}} -{{>models/modelGeneric}} +{{>modelGeneric}} {{/isEnum}} {{/model}} {{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts new file mode 100644 index 000000000000..2ce0fb93bd37 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -0,0 +1,134 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; + + + + +/** + * PetApi - interface + * @export + * @interface PetApi + */ +export class PetApiRequestFactory { + + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public addPet(pet: Pet, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public deletePet(petId: number, apiKey?: string, options?: any): RequestContext { + + + return null; + } + + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext { + + + return null; + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public findPetsByTags(tags: Array, options?: any): RequestContext { + + + return null; + } + + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public getPetById(petId: number, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public updatePet(pet: Pet, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts new file mode 100644 index 000000000000..7f5eada6f401 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -0,0 +1,71 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { Order } from '../models/Order'; + + + + +/** + * StoreApi - interface + * @export + * @interface StoreApi + */ +export class StoreApiRequestFactory { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public deleteOrder(orderId: string, options?: any): RequestContext { + + + return null; + } + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public getInventory(options?: any): RequestContext { + + + return null; + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public getOrderById(orderId: number, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public placeOrder(order: Order, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts new file mode 100644 index 000000000000..ec03ee79f79c --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -0,0 +1,129 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { User } from '../models/User'; + + + + +/** + * UserApi - interface + * @export + * @interface UserApi + */ +export class UserApiRequestFactory { + + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUser(user: User, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUsersWithArrayInput(user: Array, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUsersWithListInput(user: Array, options?: any): RequestContext { + + + return null; + } + + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public deleteUser(username: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public getUserByName(username: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public loginUser(username: string, password: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public logoutUser(options?: any): RequestContext { + + + return null; + } + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public updateUser(username: string, user: User, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts new file mode 100644 index 000000000000..b9e34a1f5363 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts @@ -0,0 +1,96 @@ +// TODO: better import syntax? + +import { ApiResponse } from '../'; +import { Pet } from '../'; +/** + * PetApi - interface + * @export + * @interface PetApi + */ +export interface PetApiInterface { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + addPet(pet: Pet, options?: any): Promise<{}>; + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + deletePet(petId: number, apiKey?: string, options?: any): Promise<{}>; + + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise>; + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + findPetsByTags(tags: Array, options?: any): Promise>; + + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + getPetById(petId: number, options?: any): Promise; + + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + updatePet(pet: Pet, options?: any): Promise<{}>; + + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{}>; + + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts new file mode 100644 index 000000000000..d289d721768d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts @@ -0,0 +1,49 @@ +// TODO: better import syntax? + +import { Order } from '../'; +/** + * StoreApi - interface + * @export + * @interface StoreApi + */ +export interface StoreApiInterface { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + deleteOrder(orderId: string, options?: any): Promise<{}>; + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + getInventory(options?: any): Promise<{ [key: string]: number; }>; + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + getOrderById(orderId: number, options?: any): Promise; + + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + placeOrder(order: Order, options?: any): Promise; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts new file mode 100644 index 000000000000..6d763d785056 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts @@ -0,0 +1,91 @@ +// TODO: better import syntax? + +import { User } from '../'; +/** + * UserApi - interface + * @export + * @interface UserApi + */ +export interface UserApiInterface { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUser(user: User, options?: any): Promise<{}>; + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUsersWithArrayInput(user: Array, options?: any): Promise<{}>; + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUsersWithListInput(user: Array, options?: any): Promise<{}>; + + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + deleteUser(username: string, options?: any): Promise<{}>; + + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + getUserByName(username: string, options?: any): Promise; + + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + loginUser(username: string, password: string, options?: any): Promise; + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + logoutUser(options?: any): Promise<{}>; + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + updateUser(username: string, user: User, options?: any): Promise<{}>; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/baseapi.ts b/samples/client/petstore/typescript/builds/default/apis/baseapi.ts new file mode 100644 index 000000000000..fe7ee3d15118 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts new file mode 100644 index 000000000000..45f839a03ab9 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts @@ -0,0 +1,30 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ +export interface ApiResponse { + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/models/Category.ts new file mode 100644 index 000000000000..c950f45dfcc1 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Category.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/models/Order.ts new file mode 100644 index 000000000000..d2699e865ee9 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Order.ts @@ -0,0 +1,64 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {Date} + * @memberof Order + */ + shipDate?: Date; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: Order.StatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @namespace Order + */ +export namespace Order { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts new file mode 100644 index 000000000000..529d264a31e2 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts @@ -0,0 +1,66 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +import { Category } from './Category'; +import { Tag } from './Tag'; +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: Pet.StatusEnum; +} + +/** + * @export + * @namespace Pet + */ +export namespace Pet { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts new file mode 100644 index 000000000000..eb777b1c6163 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/User.ts b/samples/client/petstore/typescript/builds/default/models/models/User.ts new file mode 100644 index 000000000000..247a8665e8b3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/User.ts @@ -0,0 +1,60 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} + From d4fa8c7f721a098b4d594484a304915b77f476b7 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Tue, 14 Aug 2018 22:41:28 +0200 Subject: [PATCH 09/85] Updated auth --- .../resources/typescript/auth/auth.mustache | 28 ++++++++++++++++--- .../typescript/builds/default/auth/auth.ts | 26 ++++++++++++++--- .../builds/default/configuration.ts | 1 + .../typescript/builds/default/servers.ts | 2 +- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 7d88980180e0..90a7171b6f52 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -33,11 +33,16 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { + private apiKey: string; - public constructor(authName: string, private paramName: string, private apiKey: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { super(authName); } + public setApiKey(apiKey: string) { + this.apiKey = apiKey; + } + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -50,13 +55,28 @@ export class APIKeyAuthentication extends SecurityAuthentication { } export class HttpBasicAuthentication extends SecurityAuthentication { - - public constructor(authName: string, private username: string, private password: string) { + private username: string; + private password: string; + + public constructor(authName: string) { super(authName); } + public setUserNameAndPassword(username: string, password: string) { + this.username = username; + this.password = password; + } + public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; context.setHeaderParam("Authentication", "Basic " + btoa(comb)); } -} \ No newline at end of file +} + +// TODO: add oauth2 +// TODO: check ^last +export const authMethods = { + {{#authMethods}} + "{{name}}": {{#isApiKey}}new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}){{/isApiKey}}{{#isBasic}}new HttpBasicAuthentication("{{keyParamName}}"){{/isBasic}}{{#isOAuth}}null{{/isOAuth}}{{^last}},{{/last}} + {{/authMethods}} +} diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/client/petstore/typescript/builds/default/auth/auth.ts index 7d88980180e0..17c80b1d75ab 100644 --- a/samples/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/client/petstore/typescript/builds/default/auth/auth.ts @@ -33,11 +33,16 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { + private apiKey: string; - public constructor(authName: string, private paramName: string, private apiKey: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { super(authName); } + public setApiKey(apiKey: string) { + this.apiKey = apiKey; + } + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -50,13 +55,26 @@ export class APIKeyAuthentication extends SecurityAuthentication { } export class HttpBasicAuthentication extends SecurityAuthentication { - - public constructor(authName: string, private username: string, private password: string) { + private username: string; + private password: string; + + public constructor(authName: string) { super(authName); } + public setUserNameAndPassword(username: string, password: string) { + this.username = username; + this.password = password; + } + public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; context.setHeaderParam("Authentication", "Basic " + btoa(comb)); } -} \ No newline at end of file +} + +// TODO: add oauth2 +export const authMethods = { + "api_key": new APIKeyAuthentication("api_key", "api_key", "header"), + "petstore_auth": null, +} diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index 59f971410751..a9a25e5952d9 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -7,6 +7,7 @@ export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts index 7cc55b40db0c..e91a7c80ff79 100644 --- a/samples/client/petstore/typescript/builds/default/servers.ts +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -11,5 +11,5 @@ export class ServerConfiguration { } export const servers = [ - new ServerConfiguration("http://petstore.swagger.io/v2"), + new ServerConfiguration("/"), ] From f5b062957d3bb80212176ec297ee6b696e7e27ba Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 15 Aug 2018 22:00:01 +0200 Subject: [PATCH 10/85] WIP: api modeling --- .../languages/TypeScriptClientCodegen.java | 4 +- .../typescript/ObjectSerializer.mustache | 156 ++++++ .../main/resources/typescript/api.mustache | 74 ++- .../resources/typescript/auth/auth.mustache | 66 ++- .../typescript/configuration.mustache | 25 +- .../main/resources/typescript/model.mustache | 69 +++ .../resources/typescript/modelEnum.mustache | 12 - .../typescript/modelGeneric.mustache | 41 -- .../main/resources/typescript/models.mustache | 15 - .../typescript/builds/default/apis/PetApi.ts | 309 ++++++++---- .../builds/default/apis/StoreApi.ts | 129 +++-- .../typescript/builds/default/apis/UserApi.ts | 276 +++++++---- .../builds/default/apis/apis/PetApi.ts | 96 ---- .../builds/default/apis/apis/StoreApi.ts | 49 -- .../builds/default/apis/apis/UserApi.ts | 91 ---- .../typescript/builds/default/auth/auth.ts | 61 ++- .../builds/default/configuration.ts | 25 +- .../builds/default/models/ApiResponse.ts | 54 +- .../builds/default/models/Category.ts | 42 +- .../builds/default/models/ObjectSerializer.ts | 150 ++++++ .../typescript/builds/default/models/Order.ts | 100 ++-- .../typescript/builds/default/models/Pet.ts | 102 ++-- .../typescript/builds/default/models/Tag.ts | 42 +- .../typescript/builds/default/models/User.ts | 115 +++-- .../default/models/models/ApiResponse.ts | 30 -- .../builds/default/models/models/Category.ts | 24 - .../builds/default/models/models/Order.ts | 64 --- .../builds/default/models/models/Pet.ts | 66 --- .../builds/default/models/models/Tag.ts | 24 - .../builds/default/models/models/User.ts | 60 --- .../builds/default/package-lock.json | 468 ------------------ .../typescript/builds/default/servers.ts | 2 +- 32 files changed, 1253 insertions(+), 1588 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/model.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript/models.mustache delete mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts delete mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts delete mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/Category.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/Order.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/Pet.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/Tag.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/models/User.ts delete mode 100644 samples/client/petstore/typescript/builds/default/package-lock.json diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 0408e69b81d3..2be16cfd637c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -132,8 +132,10 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); // models + // TODO: properly set model and api packages this.setModelPackage(""); - this.modelTemplateFiles.put("models.mustache", ".ts"); + supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); + modelTemplateFiles.put("model.mustache", ".ts"); // api this.setApiPackage(""); diff --git a/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache new file mode 100644 index 000000000000..842c4a89691a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache @@ -0,0 +1,156 @@ +{{#models}} +{{#model}} +export * from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +{{#models}} +{{#model}} +import { {{classname}} } from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + {{#models}} + {{#model}} + {{#hasEnums}} + {{#vars}} + {{#isEnum}} + {{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{#isNotContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isNotContainer}}, + {{/isEnum}} + {{/vars}} + {{/hasEnums}} + {{/model}} + {{/models}} +} + +let typeMap: {[index: string]: any} = { + {{#models}} + {{#model}} + "{{classname}}": {{classname}}, + {{/model}} + {{/models}} +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api.mustache index 3dd5268a4b17..fe7e4ea7ea49 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api.mustache @@ -1,39 +1,61 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; {{#imports}} import { {{classname}} } from '..{{filename}}'; {{/imports}} - - - {{#operations}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export class {{classname}}RequestFactory { +export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof {{classname}}Interface - */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { + {{#allParams}} + {{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new RequiredError('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + + {{/required}} + {{/allParams}} + + // Path Params + const localVarPath = '{{{path}}}'{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); + + // Query Params + {{#queryParams}} + if ({{paramName}} !== undefined) { + requestContext.setQueryParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + } + {{/queryParams}} + + // Header Params + {{#headerParams}} + requestContext.setHeaderParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + {{/headerParams}} + + let localVarUseFormData = false; + + // Form Params + + WE ARE HERE TODO! + let authMethod = null; + + // Apply auth methods + {{#authMethods}} + authMethod = this.configuration.authMethods["{{name}}"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + {{/authMethods}} - - return null; + return requestContext; } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 90a7171b6f52..815c5b09642f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -33,16 +33,11 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { - private apiKey: string; - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - - public setApiKey(apiKey: string) { - this.apiKey = apiKey; - } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -53,19 +48,13 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } +// TODO: guarantee that auth was configured properly export class HttpBasicAuthentication extends SecurityAuthentication { - private username: string; - private password: string; - public constructor(authName: string) { + public constructor(authName: string, private username: string, private password: string) { super(authName); } - - public setUserNameAndPassword(username: string, password: string) { - this.username = username; - this.password = password; - } public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; @@ -73,10 +62,49 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } -// TODO: add oauth2 -// TODO: check ^last -export const authMethods = { +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + +export type AuthMethods = { {{#authMethods}} - "{{name}}": {{#isApiKey}}new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}){{/isApiKey}}{{#isBasic}}new HttpBasicAuthentication("{{keyParamName}}"){{/isBasic}}{{#isOAuth}}null{{/isOAuth}}{{^last}},{{/last}} + "{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isHttp}}HttpBasicAuthentication{{/isHttp}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}}, {{/authMethods}} } + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isHttp}}HttpBasicConfiguration{{/isHttp}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } + +export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = { + } + + if (!conf) { + return authMethods; + } + + {{#authMethods}} + if (conf["{{name}}"]) { + {{#isApiKey}} + authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, conf["{{name}}"]); + {{/isApiKey}} + {{#isBasic}} + authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]); + {{/isBasic}} + {{#isOAuth}} + authMethods["{{name}}"] = new OAuth2Authentication("{{name}}"); + {{/isOAuth}} + } + + {{/authMethods}} + return authMethods; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index a9a25e5952d9..c672e9a4d00a 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -2,16 +2,14 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, servers} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests - - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security + authMethods?: AuthMethodsConfiguration } export class Configuration { @@ -19,23 +17,12 @@ export class Configuration { baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - + authMethods: AuthMethods; + constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; - if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; - } - if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; - } + this.authMethods = configureAuthMethods(conf.authMethods); } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model.mustache new file mode 100644 index 000000000000..0b3ca7589164 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/model.mustache @@ -0,0 +1,69 @@ +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#tsImports}} +import { {{classname}} } from './{{filename}}'; +{{/tsImports}} + +{{#description}} +/** +* {{{description}}} +*/ +{{/description}} +export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#vars}} +{{#description}} + /** + * {{{description}}} + */ +{{/description}} + '{{name}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; +{{/vars}} + + {{#discriminator}} + static discriminator: string | undefined = "{{discriminatorName}}"; + {{/discriminator}} + {{^discriminator}} + static discriminator: string | undefined = undefined; + {{/discriminator}} + + {{^isArrayModel}} + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + {{#vars}} + { + "name": "{{name}}", + "baseName": "{{baseName}}", + "type": "{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}" + }{{#hasMore}}, + {{/hasMore}} + {{/vars}} + ]; + + static getAttributeTypeMap() { + {{#parent}} + return super.getAttributeTypeMap().concat({{classname}}.attributeTypeMap); + {{/parent}} + {{^parent}} + return {{classname}}.attributeTypeMap; + {{/parent}} + } + {{/isArrayModel}} +} + +{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} +{{#isEnum}} + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } +{{/isEnum}} +{{/vars}} +} +{{/hasEnums}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache deleted file mode 100644 index 5fa32c28b882..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache +++ /dev/null @@ -1,12 +0,0 @@ -/** - * {{{description}}} - * @export - * @enum {string} - */ -export enum {{classname}} { -{{#allowableValues}} -{{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} -{{/enumVars}} -{{/allowableValues}} -} diff --git a/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache deleted file mode 100644 index d4ba9f7b862c..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache +++ /dev/null @@ -1,41 +0,0 @@ -/** - * {{{description}}} - * @export - * @interface {{classname}} - */ -export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ -{{#additionalPropertiesType}} - [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; - -{{/additionalPropertiesType}} -{{#vars}} - /** - * {{{description}}} - * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%> - * @memberof {{classname}} - */ - {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; -{{/vars}} -}{{#hasEnums}} - -/** - * @export - * @namespace {{classname}} - */ -export namespace {{classname}} { -{{#vars}} - {{#isEnum}} - /** - * @export - * @enum {string} - */ - export enum {{enumName}} { - {{#allowableValues}} - {{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} - {{/enumVars}} - {{/allowableValues}} - } - {{/isEnum}} -{{/vars}} -}{{/hasEnums}} diff --git a/modules/openapi-generator/src/main/resources/typescript/models.mustache b/modules/openapi-generator/src/main/resources/typescript/models.mustache deleted file mode 100644 index b39583e15a49..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/models.mustache +++ /dev/null @@ -1,15 +0,0 @@ -// tslint:disable -{{>licenseInfo}} -{{#models}} -{{#model}} -{{#imports}} -import { {{.}} } from './{{.}}'; -{{/imports}} -{{#isEnum}} -{{>modelEnum}} -{{/isEnum}} -{{^isEnum}} -{{>modelGeneric}} -{{/isEnum}} -{{/model}} -{{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 2ce0fb93bd37..83dd80c8f2bc 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -1,134 +1,255 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; +export class PetApiRequestFactory extends BaseAPIRequestFactory { + public addPet(pet: Pet, options?: any): RequestContext { + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); + } + + // Path Params + const localVarPath = '/pet'; -/** - * PetApi - interface - * @export - * @interface PetApi - */ -export class PetApiRequestFactory { + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; - /** - * - * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - public addPet(pet: Pet, options?: any): RequestContext { + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public deletePet(petId: number, apiKey?: string, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + requestContext.setHeaderParam("", ObjectSerializer.serialize(apiKey, "string")); + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext { + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + + + // Path Params + const localVarPath = '/pet/findByStatus'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (status !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); + } + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @param {Array} tags Tags to filter by - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public findPetsByTags(tags: Array, options?: any): RequestContext { + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + + + // Path Params + const localVarPath = '/pet/findByTags'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (tags !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(tags, "Array")); + } + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * Returns a single pet - * @summary Find pet by ID - * @param {number} petId ID of pet to return - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public getPetById(petId: number, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * - * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public updatePet(pet: Pet, options?: any): RequestContext { + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * - * @summary Updates a pet in the store with form data - * @param {number} petId ID of pet that needs to be updated - * @param {string} [name] Updated name of the pet - * @param {string} [status] Updated status of the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } - /** - * - * @summary uploads an image - * @param {number} petId ID of pet to update - * @param {string} [additionalMetadata] Additional data to pass to server - * @param {any} [file] file to upload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 7f5eada6f401..436d73d1f775 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -1,71 +1,110 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { Order } from '../models/Order'; +export class StoreApiRequestFactory extends BaseAPIRequestFactory { + public deleteOrder(orderId: string, options?: any): RequestContext { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); -/** - * StoreApi - interface - * @export - * @interface StoreApi - */ -export class StoreApiRequestFactory { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @param {string} orderId ID of the order that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - public deleteOrder(orderId: string, options?: any): RequestContext { + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public getInventory(options?: any): RequestContext { + + // Path Params + const localVarPath = '/store/inventory'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @param {number} orderId ID of pet that needs to be fetched - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public getOrderById(orderId: number, options?: any): RequestContext { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public placeOrder(order: Order, options?: any): RequestContext { + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + } + + + // Path Params + const localVarPath = '/store/order'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index ec03ee79f79c..3ce46788d925 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -1,129 +1,225 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { User } from '../models/User'; +export class UserApiRequestFactory extends BaseAPIRequestFactory { + public createUser(user: User, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); + } + + // Path Params + const localVarPath = '/user'; -/** - * UserApi - interface - * @export - * @interface UserApi - */ -export class UserApiRequestFactory { + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; - /** - * This can only be done by the logged in user. - * @summary Create user - * @param {User} user Created user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - public createUser(user: User, options?: any): RequestContext { + // Apply auth methods - - return null; + return requestContext; } - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public createUsersWithArrayInput(user: Array, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithArray'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public createUsersWithListInput(user: Array, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithList'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * This can only be done by the logged in user. - * @summary Delete user - * @param {string} username The name that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public deleteUser(username: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * - * @summary Get user by user name - * @param {string} username The name that needs to be fetched. Use user1 for testing. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public getUserByName(username: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * - * @summary Logs user into the system - * @param {string} username The user name for login - * @param {string} password The password for login in clear text - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public loginUser(username: string, password: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + + + // Path Params + const localVarPath = '/user/login'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (username !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(username, "string")); + } + + if (password !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(password, "string")); + } + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public logoutUser(options?: any): RequestContext { + + // Path Params + const localVarPath = '/user/logout'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } - /** - * This can only be done by the logged in user. - * @summary Updated user - * @param {string} username name that need to be deleted - * @param {User} user Updated user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public updateUser(username: string, user: User, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + + + // Form Params + + + + let authMethod = null; + + // Apply auth methods - - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts deleted file mode 100644 index b9e34a1f5363..000000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts +++ /dev/null @@ -1,96 +0,0 @@ -// TODO: better import syntax? - -import { ApiResponse } from '../'; -import { Pet } from '../'; -/** - * PetApi - interface - * @export - * @interface PetApi - */ -export interface PetApiInterface { - /** - * - * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - addPet(pet: Pet, options?: any): Promise<{}>; - - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - deletePet(petId: number, apiKey?: string, options?: any): Promise<{}>; - - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise>; - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @param {Array} tags Tags to filter by - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - findPetsByTags(tags: Array, options?: any): Promise>; - - /** - * Returns a single pet - * @summary Find pet by ID - * @param {number} petId ID of pet to return - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - getPetById(petId: number, options?: any): Promise; - - /** - * - * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - updatePet(pet: Pet, options?: any): Promise<{}>; - - /** - * - * @summary Updates a pet in the store with form data - * @param {number} petId ID of pet that needs to be updated - * @param {string} [name] Updated name of the pet - * @param {string} [status] Updated status of the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{}>; - - /** - * - * @summary uploads an image - * @param {number} petId ID of pet to update - * @param {string} [additionalMetadata] Additional data to pass to server - * @param {any} [file] file to upload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise; - -} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts deleted file mode 100644 index d289d721768d..000000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts +++ /dev/null @@ -1,49 +0,0 @@ -// TODO: better import syntax? - -import { Order } from '../'; -/** - * StoreApi - interface - * @export - * @interface StoreApi - */ -export interface StoreApiInterface { - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @param {string} orderId ID of the order that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - deleteOrder(orderId: string, options?: any): Promise<{}>; - - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - getInventory(options?: any): Promise<{ [key: string]: number; }>; - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @param {number} orderId ID of pet that needs to be fetched - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - getOrderById(orderId: number, options?: any): Promise; - - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - placeOrder(order: Order, options?: any): Promise; - -} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts deleted file mode 100644 index 6d763d785056..000000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts +++ /dev/null @@ -1,91 +0,0 @@ -// TODO: better import syntax? - -import { User } from '../'; -/** - * UserApi - interface - * @export - * @interface UserApi - */ -export interface UserApiInterface { - /** - * This can only be done by the logged in user. - * @summary Create user - * @param {User} user Created user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUser(user: User, options?: any): Promise<{}>; - - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUsersWithArrayInput(user: Array, options?: any): Promise<{}>; - - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUsersWithListInput(user: Array, options?: any): Promise<{}>; - - /** - * This can only be done by the logged in user. - * @summary Delete user - * @param {string} username The name that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - deleteUser(username: string, options?: any): Promise<{}>; - - /** - * - * @summary Get user by user name - * @param {string} username The name that needs to be fetched. Use user1 for testing. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - getUserByName(username: string, options?: any): Promise; - - /** - * - * @summary Logs user into the system - * @param {string} username The user name for login - * @param {string} password The password for login in clear text - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - loginUser(username: string, password: string, options?: any): Promise; - - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - logoutUser(options?: any): Promise<{}>; - - /** - * This can only be done by the logged in user. - * @summary Updated user - * @param {string} username name that need to be deleted - * @param {User} user Updated user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - updateUser(username: string, user: User, options?: any): Promise<{}>; - -} diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/client/petstore/typescript/builds/default/auth/auth.ts index 17c80b1d75ab..a04aeb110da1 100644 --- a/samples/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/client/petstore/typescript/builds/default/auth/auth.ts @@ -33,16 +33,11 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { - private apiKey: string; - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - - public setApiKey(apiKey: string) { - this.apiKey = apiKey; - } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -53,19 +48,13 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } +// TODO: guarantee that auth was configured properly export class HttpBasicAuthentication extends SecurityAuthentication { - private username: string; - private password: string; - public constructor(authName: string) { + public constructor(authName: string, private username: string, private password: string) { super(authName); } - - public setUserNameAndPassword(username: string, password: string) { - this.username = username; - this.password = password; - } public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; @@ -73,8 +62,42 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } -// TODO: add oauth2 -export const authMethods = { - "api_key": new APIKeyAuthentication("api_key", "api_key", "header"), - "petstore_auth": null, +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + +export type AuthMethods = { + "api_key"?: APIKeyAuthentication, + "petstore_auth"?: OAuth2Authentication, } + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } + +export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = { + } + + if (!conf) { + return authMethods; + } + + if (conf["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + } + + if (conf["petstore_auth"]) { + authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); + } + + return authMethods; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index a9a25e5952d9..c672e9a4d00a 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -2,16 +2,14 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, servers} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests - - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security + authMethods?: AuthMethodsConfiguration } export class Configuration { @@ -19,23 +17,12 @@ export class Configuration { baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - + authMethods: AuthMethods; + constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; - if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; - } - if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; - } + this.authMethods = configureAuthMethods(conf.authMethods); } } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index 45f839a03ab9..2624f2e5065f 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -1,30 +1,36 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ -export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; +* Describes the result of uploading an image resource +*/ +export class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "number" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + }, + { + "name": "message", + "baseName": "message", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ApiResponse.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index c950f45dfcc1..f16c4fb2ea7e 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -1,24 +1,30 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; +* A category for a pet +*/ +export class Category { + 'id'?: number; + 'name'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Category.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts new file mode 100644 index 000000000000..f1ef2d30044d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -0,0 +1,150 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + +import { ApiResponse } from './ApiResponse'; +import { Category } from './Category'; +import { Order } from './Order'; +import { Pet } from './Pet'; +import { Tag } from './Tag'; +import { User } from './User'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + "Order.StatusEnum": Order.StatusEnum, + "Pet.StatusEnum": Pet.StatusEnum, +} + +let typeMap: {[index: string]: any} = { + "ApiResponse": ApiResponse, + "Category": Category, + "Order": Order, + "Pet": Pet, + "Tag": Tag, + "User": User, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index d2699e865ee9..8527b6f208f7 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -1,64 +1,64 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * An order for a pets from the pet store - * @export - * @interface Order - */ -export interface Order { - /** - * - * @type {number} - * @memberof Order - */ - id?: number; - /** - * - * @type {number} - * @memberof Order - */ - petId?: number; - /** - * - * @type {number} - * @memberof Order - */ - quantity?: number; - /** - * - * @type {Date} - * @memberof Order - */ - shipDate?: Date; - /** - * Order Status - * @type {string} - * @memberof Order - */ - status?: Order.StatusEnum; +* An order for a pets from the pet store +*/ +export class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; /** - * - * @type {boolean} - * @memberof Order - */ - complete?: boolean; + * Order Status + */ + 'status'?: Order.StatusEnum; + 'complete'?: boolean; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date" + }, + { + "name": "status", + "baseName": "status", + "type": "Order.StatusEnum" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean" + } ]; + + static getAttributeTypeMap() { + return Order.attributeTypeMap; + } } -/** - * @export - * @namespace Order - */ export namespace Order { - /** - * @export - * @enum {string} - */ export enum StatusEnum { Placed = 'placed', Approved = 'approved', Delivered = 'delivered' } } - diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 529d264a31e2..793b68f75e8e 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -1,66 +1,64 @@ -// tslint:disable /* TODO: LICENSE INFO */ -import { Category } from './Category'; -import { Tag } from './Tag'; + /** - * A pet for sale in the pet store - * @export - * @interface Pet - */ -export interface Pet { - /** - * - * @type {number} - * @memberof Pet - */ - id?: number; - /** - * - * @type {Category} - * @memberof Pet - */ - category?: Category; - /** - * - * @type {string} - * @memberof Pet - */ - name: string; - /** - * - * @type {Array} - * @memberof Pet - */ - photoUrls: Array; - /** - * - * @type {Array} - * @memberof Pet - */ - tags?: Array; +* A pet for sale in the pet store +*/ +export class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; /** - * pet status in the store - * @type {string} - * @memberof Pet - */ - status?: Pet.StatusEnum; + * pet status in the store + */ + 'status'?: Pet.StatusEnum; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "category", + "baseName": "category", + "type": "Category" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array" + }, + { + "name": "status", + "baseName": "status", + "type": "Pet.StatusEnum" + } ]; + + static getAttributeTypeMap() { + return Pet.attributeTypeMap; + } } -/** - * @export - * @namespace Pet - */ export namespace Pet { - /** - * @export - * @enum {string} - */ export enum StatusEnum { Available = 'available', Pending = 'pending', Sold = 'sold' } } - diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index eb777b1c6163..e1434bd3d136 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -1,24 +1,30 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; +* A tag for a pet +*/ +export class Tag { + 'id'?: number; + 'name'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Tag.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index 247a8665e8b3..15df044dbf8c 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -1,60 +1,69 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A User who is purchasing from the pet store - * @export - * @interface User - */ -export interface User { - /** - * - * @type {number} - * @memberof User - */ - id?: number; - /** - * - * @type {string} - * @memberof User - */ - username?: string; - /** - * - * @type {string} - * @memberof User - */ - firstName?: string; - /** - * - * @type {string} - * @memberof User - */ - lastName?: string; - /** - * - * @type {string} - * @memberof User - */ - email?: string; - /** - * - * @type {string} - * @memberof User - */ - password?: string; - /** - * - * @type {string} - * @memberof User - */ - phone?: string; +* A User who is purchasing from the pet store +*/ +export class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; /** - * User Status - * @type {number} - * @memberof User - */ - userStatus?: number; + * User Status + */ + 'userStatus'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "username", + "baseName": "username", + "type": "string" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "password", + "baseName": "password", + "type": "string" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return User.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts deleted file mode 100644 index 45f839a03ab9..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts +++ /dev/null @@ -1,30 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ -export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/models/Category.ts deleted file mode 100644 index c950f45dfcc1..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Category.ts +++ /dev/null @@ -1,24 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/models/Order.ts deleted file mode 100644 index d2699e865ee9..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Order.ts +++ /dev/null @@ -1,64 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ -export interface Order { - /** - * - * @type {number} - * @memberof Order - */ - id?: number; - /** - * - * @type {number} - * @memberof Order - */ - petId?: number; - /** - * - * @type {number} - * @memberof Order - */ - quantity?: number; - /** - * - * @type {Date} - * @memberof Order - */ - shipDate?: Date; - /** - * Order Status - * @type {string} - * @memberof Order - */ - status?: Order.StatusEnum; - /** - * - * @type {boolean} - * @memberof Order - */ - complete?: boolean; -} - -/** - * @export - * @namespace Order - */ -export namespace Order { - /** - * @export - * @enum {string} - */ - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts deleted file mode 100644 index 529d264a31e2..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts +++ /dev/null @@ -1,66 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -import { Category } from './Category'; -import { Tag } from './Tag'; -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ -export interface Pet { - /** - * - * @type {number} - * @memberof Pet - */ - id?: number; - /** - * - * @type {Category} - * @memberof Pet - */ - category?: Category; - /** - * - * @type {string} - * @memberof Pet - */ - name: string; - /** - * - * @type {Array} - * @memberof Pet - */ - photoUrls: Array; - /** - * - * @type {Array} - * @memberof Pet - */ - tags?: Array; - /** - * pet status in the store - * @type {string} - * @memberof Pet - */ - status?: Pet.StatusEnum; -} - -/** - * @export - * @namespace Pet - */ -export namespace Pet { - /** - * @export - * @enum {string} - */ - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts deleted file mode 100644 index eb777b1c6163..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts +++ /dev/null @@ -1,24 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/User.ts b/samples/client/petstore/typescript/builds/default/models/models/User.ts deleted file mode 100644 index 247a8665e8b3..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/User.ts +++ /dev/null @@ -1,60 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ -export interface User { - /** - * - * @type {number} - * @memberof User - */ - id?: number; - /** - * - * @type {string} - * @memberof User - */ - username?: string; - /** - * - * @type {string} - * @memberof User - */ - firstName?: string; - /** - * - * @type {string} - * @memberof User - */ - lastName?: string; - /** - * - * @type {string} - * @memberof User - */ - email?: string; - /** - * - * @type {string} - * @memberof User - */ - password?: string; - /** - * - * @type {string} - * @memberof User - */ - phone?: string; - /** - * User Status - * @type {number} - * @memberof User - */ - userStatus?: number; -} - diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json deleted file mode 100644 index c1d83a3dec01..000000000000 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ /dev/null @@ -1,468 +0,0 @@ -{ - "name": "ts-petstore-client", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/chai": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", - "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", - "dev": true - }, - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - } - }, - "@types/isomorphic-fetch": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", - "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" - }, - "@types/mocha": { - "version": "5.2.5", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", - "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", - "dev": true - }, - "@types/node": { - "version": "10.5.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz", - "integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ==" - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "btoa": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", - "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" - }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "dev": true, - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, - "make-error": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", - "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==", - "dev": true - }, - "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" - }, - "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", - "requires": { - "mime-db": "~1.35.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, - "querystringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", - "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==" - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "source-map-support": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz", - "integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "ts-node": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", - "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", - "dev": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", - "dev": true - }, - "url-parse": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", - "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", - "requires": { - "querystringify": "^2.0.0", - "requires-port": "^1.0.0" - } - }, - "whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", - "dev": true - } - } -} diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts index e91a7c80ff79..7cc55b40db0c 100644 --- a/samples/client/petstore/typescript/builds/default/servers.ts +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -11,5 +11,5 @@ export class ServerConfiguration { } export const servers = [ - new ServerConfiguration("/"), + new ServerConfiguration("http://petstore.swagger.io/v2"), ] From a8ec86611752afd2139f39d3d9fc1e3e335be039 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 13 Oct 2018 15:25:53 +0200 Subject: [PATCH 11/85] Implemented RequestFactory and Processor completely --- .../languages/TypeScriptClientCodegen.java | 23 +- .../main/resources/typescript/api.mustache | 94 +++- .../generators/fetch/fetch.mustache | 16 + .../resources/typescript/tsconfig.mustache | 6 +- .../typescript/builds/default/apis/PetApi.ts | 272 ++++++++-- .../builds/default/apis/StoreApi.ts | 134 ++++- .../typescript/builds/default/apis/UserApi.ts | 254 ++++++++-- .../builds/default/dist/apis/PetApi.d.ts | 24 + .../builds/default/dist/apis/PetApi.js | 237 +++++++++ .../builds/default/dist/apis/PetApi.js.map | 1 + .../builds/default/dist/apis/StoreApi.d.ts | 17 + .../builds/default/dist/apis/StoreApi.js | 109 ++++ .../builds/default/dist/apis/StoreApi.js.map | 1 + .../builds/default/dist/apis/UserApi.d.ts | 23 + .../builds/default/dist/apis/UserApi.js | 181 +++++++ .../builds/default/dist/apis/UserApi.js.map | 1 + .../builds/default/dist/apis/baseapi.d.ts | 16 + .../builds/default/dist/apis/baseapi.js | 41 ++ .../builds/default/dist/apis/baseapi.js.map | 1 + .../builds/default/dist/auth/auth.d.ts | 43 ++ .../builds/default/dist/auth/auth.js | 99 ++++ .../builds/default/dist/auth/auth.js.map | 1 + .../builds/default/dist/configuration.d.ts | 17 + .../builds/default/dist/configuration.js | 17 + .../builds/default/dist/configuration.js.map | 1 + .../builds/default/dist/fetch/api.d.ts | 0 .../builds/default/dist/fetch/api.js | 2 + .../builds/default/dist/fetch/api.js.map | 1 + .../builds/default/dist/http/http.d.ts | 50 ++ .../builds/default/dist/http/http.js | 91 ++++ .../builds/default/dist/http/http.js.map | 1 + .../default/dist/http/isomorphic-fetch.d.ts | 5 + .../default/dist/http/isomorphic-fetch.js | 31 ++ .../default/dist/http/isomorphic-fetch.js.map | 1 + .../typescript/builds/default/dist/index.d.ts | 6 + .../typescript/builds/default/dist/index.js | 11 + .../builds/default/dist/index.js.map | 1 + .../builds/default/dist/middleware.d.ts | 5 + .../builds/default/dist/middleware.js | 3 + .../builds/default/dist/middleware.js.map | 1 + .../default/dist/models/ApiResponse.d.ts | 16 + .../builds/default/dist/models/ApiResponse.js | 30 ++ .../default/dist/models/ApiResponse.js.map | 1 + .../builds/default/dist/models/Category.d.ts | 15 + .../builds/default/dist/models/Category.js | 25 + .../default/dist/models/Category.js.map | 1 + .../default/dist/models/ObjectSerializer.d.ts | 11 + .../default/dist/models/ObjectSerializer.js | 157 ++++++ .../dist/models/ObjectSerializer.js.map | 1 + .../builds/default/dist/models/Order.d.ts | 26 + .../builds/default/dist/models/Order.js | 54 ++ .../builds/default/dist/models/Order.js.map | 1 + .../builds/default/dist/models/Pet.d.ts | 28 ++ .../builds/default/dist/models/Pet.js | 54 ++ .../builds/default/dist/models/Pet.js.map | 1 + .../builds/default/dist/models/Tag.d.ts | 15 + .../builds/default/dist/models/Tag.js | 25 + .../builds/default/dist/models/Tag.js.map | 1 + .../builds/default/dist/models/User.d.ts | 21 + .../builds/default/dist/models/User.js | 55 ++ .../builds/default/dist/models/User.js.map | 1 + .../builds/default/dist/servers.d.ts | 7 + .../typescript/builds/default/dist/servers.js | 17 + .../builds/default/dist/servers.js.map | 1 + .../typescript/builds/default/models/Pet.ts | 2 + .../builds/default/package-lock.json | 468 ++++++++++++++++++ .../typescript/builds/default/tsconfig.json | 6 +- 67 files changed, 2734 insertions(+), 144 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/index.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/index.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/index.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.js.map create mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.d.ts create mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.js create mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.js.map create mode 100644 samples/client/petstore/typescript/builds/default/package-lock.json diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 2be16cfd637c..44fe38314c21 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -492,7 +492,7 @@ public String toEnumName(CodegenProperty property) { @Override public Map postProcessModels(Map objs) { // process enum in models - List models = (List) postProcessModelsEnum(objs).get("models"); + List> models = (List>) postProcessModelsEnum(objs).get("models"); for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); @@ -512,10 +512,29 @@ public Map postProcessModels(Map objs) { } } } - + for (Map mo : models) { + CodegenModel cm = (CodegenModel) mo.get("model"); + // Add additional filename information for imports + mo.put("tsImports", toTsImports(cm, cm.imports)); + } return objs; } + private List> toTsImports(CodegenModel cm, Set imports) { + List> tsImports = new ArrayList<>(); + for (String im : imports) { + if (!im.equals(cm.classname)) { + HashMap tsImport = new HashMap<>(); + // TVG: This is used as class name in the import statements of the model file + tsImport.put("classname", im); + tsImport.put("filename", toModelFilename(im)); + tsImports.add(tsImport); + } + } + return tsImports; + } + + @Override public Map postProcessAllModels(Map objs) { Map result = super.postProcessAllModels(objs); diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api.mustache index fe7e4ea7ea49..24bc3c775a90 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api.mustache @@ -1,6 +1,7 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod } from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; {{#imports}} import { {{classname}} } from '..{{filename}}'; @@ -8,7 +9,8 @@ import { {{classname}} } from '..{{filename}}'; {{#operations}} export class {{classname}}RequestFactory extends BaseAPIRequestFactory { - + // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + {{#operation}} public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { {{#allParams}} @@ -40,13 +42,54 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); {{/headerParams}} - let localVarUseFormData = false; - // Form Params - - WE ARE HERE TODO! - let authMethod = null; + {{#hasFormParams}} + let localVarFormParams = new FormData(); + {{/hasFormParams}} + + {{#formParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + localVarFormParams.append('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + // TODO: replace .append with .set + localVarFormParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('{{baseName}}', {{paramName}} as any); + } + {{/isListContainer}} + {{/formParams}} + {{#hasFormParams}} + requestContext.setBody(localVarFormParams); + {{/hasFormParams}} + // Body Params + {{#bodyParam}} + {{^consumes}} + requestContext.setHeaderParam("Content-Type", "application/json"); + {{/consumes}} + // TODO: deal with this? Could be useful for server definition + {{#consumes.0}} + requestContext.setHeaderParam("Content-Type", "{{{mediaType}}}"); + {{/consumes.0}} + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("{{dataType}}" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}}.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + {{/bodyParam}} + + {{#hasAuthMethods}} + let authMethod = null; + {{/hasAuthMethods}} // Apply auth methods {{#authMethods}} authMethod = this.configuration.authMethods["{{name}}"] @@ -60,4 +103,39 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{/operation}} } -{{/operations}} \ No newline at end of file +{{/operations}} + +// TODO: find way to split these two files (both dependent on apitemplatefiles) + + +{{#operations}} + +export class {{classname}}ResponseProcessor { + + {{#operation}} + /** + * + * @throws {{{returnType}}} if the httpStatusCode is not in [200, 299] + */ + public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + {{#returnType}} + const body: {{{returnType}}} = ObjectSerializer.deserialize(response.body, "{{{returnType}}}") as {{{returnType}}}; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + {{/returnType}} + {{^returnType}} + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + {{/returnType}} + } + + {{/operation}} +} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache new file mode 100644 index 000000000000..96d5b6951194 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache @@ -0,0 +1,16 @@ +# TODO: + +# Generic for HTTP Library: + + # Generate one class for each api + # constructor: Configuration + RequestFactory + ResponseProcessor + # one method for each API + # call request factory + # execute request with http library or w/e other library + # call response processor + # return promise + + # Why is this good? Because it allows each generator to return whatever they want to return, but they rely on the same + # internal process to get the response (if done correctly...) + +# Export correctly configured apis! \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache index 6223bc4d7cfa..103a5de86358 100644 --- a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache @@ -7,8 +7,8 @@ "declaration": true, /* Additional Checks */ - "noUnusedLocals": true, /* Report errors on unused locals. */ - "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ @@ -16,10 +16,10 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "declaration": true, "lib": [ "es6", "dom" ] }, "exclude": [ + "dist", "node_modules" ], "filesGlob": [ diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 83dd80c8f2bc..08ae13543576 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -1,12 +1,14 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod } from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; export class PetApiRequestFactory extends BaseAPIRequestFactory { - + // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + public addPet(pet: Pet, options?: any): RequestContext { // verify required parameter 'pet' is not null or undefined if (pet === null || pet === undefined) { @@ -20,13 +22,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // TODO: deal with this? Could be useful for server definition + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -50,14 +61,17 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + // Query Params + + // Header Params requestContext.setHeaderParam("", ObjectSerializer.serialize(apiKey, "string")); - - // Form Params - - - - let authMethod = null; + + // Form Params + + // Body Params + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -80,17 +94,19 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + // Query Params if (status !== undefined) { requestContext.setQueryParam("", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); } + + // Header Params + + // Form Params + + + // Body Params - - // Form Params - - - let authMethod = null; - // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -113,17 +129,19 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + // Query Params if (tags !== undefined) { requestContext.setQueryParam("", ObjectSerializer.serialize(tags, "Array")); } + + // Header Params + + // Form Params + + + // Body Params - - // Form Params - - - let authMethod = null; - // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -147,13 +165,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["api_key"] if (authMethod) { @@ -176,13 +197,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // TODO: deal with this? Could be useful for server definition + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -206,13 +236,26 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + if (name !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('name', name as any); + } + if (status !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('status', status as any); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -236,13 +279,26 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (additionalMetadata !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + if (file !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('file', file as any); + } + requestContext.setBody(localVarFormParams); + // Body Params + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["petstore_auth"] if (authMethod) { @@ -253,3 +309,119 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { } } + +// TODO: find way to split these two files (both dependent on apitemplatefiles) + + + +export class PetApiResponseProcessor { + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public addPet(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public deletePet(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws Array if the httpStatusCode is not in [200, 299] + */ + public findPetsByStatus(response: ResponseContext): Array { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: Array = ObjectSerializer.deserialize(response.body, "Array") as Array; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws Array if the httpStatusCode is not in [200, 299] + */ + public findPetsByTags(response: ResponseContext): Array { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: Array = ObjectSerializer.deserialize(response.body, "Array") as Array; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws Pet if the httpStatusCode is not in [200, 299] + */ + public getPetById(response: ResponseContext): Pet { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: Pet = ObjectSerializer.deserialize(response.body, "Pet") as Pet; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public updatePet(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public updatePetWithForm(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws ApiResponse if the httpStatusCode is not in [200, 299] + */ + public uploadFile(response: ResponseContext): ApiResponse { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: ApiResponse = ObjectSerializer.deserialize(response.body, "ApiResponse") as ApiResponse; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 436d73d1f775..f3d7a4b1ad72 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -1,11 +1,13 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod } from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import { Order } from '../models/Order'; export class StoreApiRequestFactory extends BaseAPIRequestFactory { - + // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + public deleteOrder(orderId: string, options?: any): RequestContext { // verify required parameter 'orderId' is not null or undefined if (orderId === null || orderId === undefined) { @@ -20,13 +22,15 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -40,13 +44,16 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + + let authMethod = null; // Apply auth methods authMethod = this.configuration.authMethods["api_key"] if (authMethod) { @@ -70,13 +77,15 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -95,16 +104,89 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: deal with this? Could be useful for server definition + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(order || {}) : (order.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + // Apply auth methods return requestContext; } } + +// TODO: find way to split these two files (both dependent on apitemplatefiles) + + + +export class StoreApiResponseProcessor { + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public deleteOrder(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws { [key: string]: number; } if the httpStatusCode is not in [200, 299] + */ + public getInventory(response: ResponseContext): { [key: string]: number; } { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: { [key: string]: number; } = ObjectSerializer.deserialize(response.body, "{ [key: string]: number; }") as { [key: string]: number; }; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws Order if the httpStatusCode is not in [200, 299] + */ + public getOrderById(response: ResponseContext): Order { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: Order = ObjectSerializer.deserialize(response.body, "Order") as Order; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws Order if the httpStatusCode is not in [200, 299] + */ + public placeOrder(response: ResponseContext): Order { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: Order = ObjectSerializer.deserialize(response.body, "Order") as Order; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index 3ce46788d925..dc2b564e4238 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -1,11 +1,13 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod } from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import { User } from '../models/User'; export class UserApiRequestFactory extends BaseAPIRequestFactory { - + // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + public createUser(user: User, options?: any): RequestContext { // verify required parameter 'user' is not null or undefined if (user === null || user === undefined) { @@ -19,13 +21,21 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: deal with this? Could be useful for server definition + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + // Apply auth methods return requestContext; @@ -44,13 +54,21 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: deal with this? Could be useful for server definition + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + // Apply auth methods return requestContext; @@ -69,13 +87,21 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: deal with this? Could be useful for server definition + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + // Apply auth methods return requestContext; @@ -95,13 +121,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -121,13 +149,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -151,21 +181,21 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + // Query Params if (username !== undefined) { requestContext.setQueryParam("", ObjectSerializer.serialize(username, "string")); } - if (password !== undefined) { requestContext.setQueryParam("", ObjectSerializer.serialize(password, "string")); } - - - // Form Params - - - - let authMethod = null; + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -179,13 +209,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + // Apply auth methods return requestContext; @@ -210,16 +242,134 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - - // Form Params - - - - let authMethod = null; + // Query Params + + // Header Params + + // Form Params + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: deal with this? Could be useful for server definition + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + // Apply auth methods return requestContext; } } + +// TODO: find way to split these two files (both dependent on apitemplatefiles) + + + +export class UserApiResponseProcessor { + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public createUser(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public createUsersWithArrayInput(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public createUsersWithListInput(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public deleteUser(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws User if the httpStatusCode is not in [200, 299] + */ + public getUserByName(response: ResponseContext): User { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: User = ObjectSerializer.deserialize(response.body, "User") as User; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws string if the httpStatusCode is not in [200, 299] + */ + public loginUser(response: ResponseContext): string { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + const body: string = ObjectSerializer.deserialize(response.body, "string") as string; + if (responseOK) { + return body; + } else { + // TODO: deal with different errors based on httpStatusCode + throw body + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public logoutUser(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + + /** + * + * @throws if the httpStatusCode is not in [200, 299] + */ + public updateUser(response: ResponseContext): void { + const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + // TODO: make this based on status code! + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + } + +} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts new file mode 100644 index 000000000000..7dee88203bf8 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts @@ -0,0 +1,24 @@ +import { BaseAPIRequestFactory } from './baseapi'; +import { RequestContext, ResponseContext } from '../http/http'; +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; +export declare class PetApiRequestFactory extends BaseAPIRequestFactory { + addPet(pet: Pet, options?: any): RequestContext; + deletePet(petId: number, apiKey?: string, options?: any): RequestContext; + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext; + findPetsByTags(tags: Array, options?: any): RequestContext; + getPetById(petId: number, options?: any): RequestContext; + updatePet(pet: Pet, options?: any): RequestContext; + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext; + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext; +} +export declare class PetApiResponseProcessor { + addPet(response: ResponseContext): void; + deletePet(response: ResponseContext): void; + findPetsByStatus(response: ResponseContext): Array; + findPetsByTags(response: ResponseContext): Array; + getPetById(response: ResponseContext): Pet; + updatePet(response: ResponseContext): void; + updatePetWithForm(response: ResponseContext): void; + uploadFile(response: ResponseContext): ApiResponse; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js new file mode 100644 index 000000000000..025572b4435b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js @@ -0,0 +1,237 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var baseapi_1 = require("./baseapi"); +var http_1 = require("../http/http"); +var FormData = require("form-data"); +var ObjectSerializer_1 = require("../models/ObjectSerializer"); +var PetApiRequestFactory = (function (_super) { + __extends(PetApiRequestFactory, _super); + function PetApiRequestFactory() { + return _super !== null && _super.apply(this, arguments) || this; + } + PetApiRequestFactory.prototype.addPet = function (pet, options) { + if (pet === null || pet === undefined) { + throw new baseapi_1.RequiredError('Required parameter pet was null or undefined when calling addPet.'); + } + var localVarPath = '/pet'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); + requestContext.setBody(serializedBody); + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.deletePet = function (petId, apiKey, options) { + if (petId === null || petId === undefined) { + throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + var localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); + requestContext.setHeaderParam("", ObjectSerializer_1.ObjectSerializer.serialize(apiKey, "string")); + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.findPetsByStatus = function (status, options) { + if (status === null || status === undefined) { + throw new baseapi_1.RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + var localVarPath = '/pet/findByStatus'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + if (status !== undefined) { + requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); + } + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.findPetsByTags = function (tags, options) { + if (tags === null || tags === undefined) { + throw new baseapi_1.RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + var localVarPath = '/pet/findByTags'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + if (tags !== undefined) { + requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(tags, "Array")); + } + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.getPetById = function (petId, options) { + if (petId === null || petId === undefined) { + throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + var localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + var authMethod = null; + authMethod = this.configuration.authMethods["api_key"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.updatePet = function (pet, options) { + if (pet === null || pet === undefined) { + throw new baseapi_1.RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + } + var localVarPath = '/pet'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PUT); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); + requestContext.setBody(serializedBody); + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.updatePetWithForm = function (petId, name, status, options) { + if (petId === null || petId === undefined) { + throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + var localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + var localVarFormParams = new FormData(); + if (name !== undefined) { + localVarFormParams.append('name', name); + } + if (status !== undefined) { + localVarFormParams.append('status', status); + } + requestContext.setBody(localVarFormParams); + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + PetApiRequestFactory.prototype.uploadFile = function (petId, additionalMetadata, file, options) { + if (petId === null || petId === undefined) { + throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + var localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + var localVarFormParams = new FormData(); + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata); + } + if (file !== undefined) { + localVarFormParams.append('file', file); + } + requestContext.setBody(localVarFormParams); + var authMethod = null; + authMethod = this.configuration.authMethods["petstore_auth"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + return PetApiRequestFactory; +}(baseapi_1.BaseAPIRequestFactory)); +exports.PetApiRequestFactory = PetApiRequestFactory; +var PetApiResponseProcessor = (function () { + function PetApiResponseProcessor() { + } + PetApiResponseProcessor.prototype.addPet = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + PetApiResponseProcessor.prototype.deletePet = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + PetApiResponseProcessor.prototype.findPetsByStatus = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Array"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + PetApiResponseProcessor.prototype.findPetsByTags = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Array"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + PetApiResponseProcessor.prototype.getPetById = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Pet"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + PetApiResponseProcessor.prototype.updatePet = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + PetApiResponseProcessor.prototype.updatePetWithForm = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + PetApiResponseProcessor.prototype.uploadFile = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "ApiResponse"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + return PetApiResponseProcessor; +}()); +exports.PetApiResponseProcessor = PetApiResponseProcessor; +//# sourceMappingURL=PetApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map new file mode 100644 index 000000000000..68cc5a3fc75f --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PetApi.js","sourceRoot":"","sources":["../../apis/PetApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAC1E,oCAAsC;AACtC,+DAA4D;AAI5D;IAA0C,wCAAqB;IAA/D;;IA8SA,CAAC;IA3SU,qCAAM,GAAb,UAAc,GAAQ,EAAE,OAAa;QAEjC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,uBAAa,CAAC,mEAAmE,CAAC,CAAC;SAChG;QAIJ,IAAM,YAAY,GAAG,MAAM,CAAC;QAG5B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAWpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAElE,IAAM,kBAAkB,GAAG,CAAM,KAAK,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC3H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/F,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE7C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wCAAS,GAAhB,UAAiB,KAAa,EAAE,MAAe,EAAE,OAAa;QAE1D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAK5G,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAOhF,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,+CAAgB,GAAvB,UAAwB,MAA+C,EAAE,OAAa;QAElF,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE;YACzC,MAAM,IAAI,uBAAa,CAAC,gFAAgF,CAAC,CAAC;SAC7G;QAIJ,IAAM,YAAY,GAAG,mBAAmB,CAAC;QAGzC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,CAAC;SAChH;QASP,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAc,GAArB,UAAsB,IAAmB,EAAE,OAAa;QAEpD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,iBAAiB,CAAC;QAGvC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;SACpF;QASP,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAU,GAAjB,UAAkB,KAAa,EAAE,OAAa;QAE1C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWzG,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wCAAS,GAAhB,UAAiB,GAAQ,EAAE,OAAa;QAEpC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,uBAAa,CAAC,sEAAsE,CAAC,CAAC;SACnG;QAIJ,IAAM,YAAY,GAAG,MAAM,CAAC;QAG5B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWnG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAElE,IAAM,kBAAkB,GAAG,CAAM,KAAK,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC3H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/F,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE7C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,gDAAiB,GAAxB,UAAyB,KAAa,EAAE,IAAa,EAAE,MAAe,EAAE,OAAa;QAEjF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,gFAAgF,CAAC,CAAC;SAC7G;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAO1G,IAAI,kBAAkB,GAAG,IAAI,QAAQ,EAAE,CAAC;QAElC,IAAI,IAAI,KAAK,SAAS,EAAE;YAEpB,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAW,CAAC,CAAC;SAClD;QACD,IAAI,MAAM,KAAK,SAAS,EAAE;YAEtB,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAa,CAAC,CAAC;SACtD;QACP,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAI3C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAU,GAAjB,UAAkB,KAAa,EAAE,kBAA2B,EAAE,IAAU,EAAE,OAAa;QAEnF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,0BAA0B;aACvC,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAO1G,IAAI,kBAAkB,GAAG,IAAI,QAAQ,EAAE,CAAC;QAElC,IAAI,kBAAkB,KAAK,SAAS,EAAE;YAElC,kBAAkB,CAAC,MAAM,CAAC,oBAAoB,EAAE,kBAAyB,CAAC,CAAC;SAC9E;QACD,IAAI,IAAI,KAAK,SAAS,EAAE;YAEpB,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAW,CAAC,CAAC;SAClD;QACP,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAI3C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,2BAAC;AAAD,CAAC,AA9SD,CAA0C,+BAAqB,GA8S9D;AA9SY,oDAAoB;AAoTjC;IAAA;IA8GA,CAAC;IAxGU,wCAAM,GAAb,UAAc,QAAyB;QACtC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,2CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,kDAAgB,GAAvB,UAAwB,QAAyB;QAChD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAe,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAe,CAAC;QACjG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,gDAAc,GAArB,UAAsB,QAAyB;QAC9C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAe,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAe,CAAC;QACjG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,4CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAQ,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAQ,CAAC;QAC5E,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,2CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,mDAAiB,GAAxB,UAAyB,QAAyB;QACjD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,4CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAgB,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAgB,CAAC;QACpG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAEL,8BAAC;AAAD,CAAC,AA9GD,IA8GC;AA9GY,0DAAuB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts new file mode 100644 index 000000000000..9d13d1b8e21f --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts @@ -0,0 +1,17 @@ +import { BaseAPIRequestFactory } from './baseapi'; +import { RequestContext, ResponseContext } from '../http/http'; +import { Order } from '../models/Order'; +export declare class StoreApiRequestFactory extends BaseAPIRequestFactory { + deleteOrder(orderId: string, options?: any): RequestContext; + getInventory(options?: any): RequestContext; + getOrderById(orderId: number, options?: any): RequestContext; + placeOrder(order: Order, options?: any): RequestContext; +} +export declare class StoreApiResponseProcessor { + deleteOrder(response: ResponseContext): void; + getInventory(response: ResponseContext): { + [key: string]: number; + }; + getOrderById(response: ResponseContext): Order; + placeOrder(response: ResponseContext): Order; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js new file mode 100644 index 000000000000..492d1205d61e --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js @@ -0,0 +1,109 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var baseapi_1 = require("./baseapi"); +var http_1 = require("../http/http"); +var ObjectSerializer_1 = require("../models/ObjectSerializer"); +var StoreApiRequestFactory = (function (_super) { + __extends(StoreApiRequestFactory, _super); + function StoreApiRequestFactory() { + return _super !== null && _super.apply(this, arguments) || this; + } + StoreApiRequestFactory.prototype.deleteOrder = function (orderId, options) { + if (orderId === null || orderId === undefined) { + throw new baseapi_1.RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + var localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); + return requestContext; + }; + StoreApiRequestFactory.prototype.getInventory = function (options) { + var localVarPath = '/store/inventory'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + var authMethod = null; + authMethod = this.configuration.authMethods["api_key"]; + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + return requestContext; + }; + StoreApiRequestFactory.prototype.getOrderById = function (orderId, options) { + if (orderId === null || orderId === undefined) { + throw new baseapi_1.RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + var localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + return requestContext; + }; + StoreApiRequestFactory.prototype.placeOrder = function (order, options) { + if (order === null || order === undefined) { + throw new baseapi_1.RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + } + var localVarPath = '/store/order'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(order || {}) : (order.toString() || ""); + requestContext.setBody(serializedBody); + return requestContext; + }; + return StoreApiRequestFactory; +}(baseapi_1.BaseAPIRequestFactory)); +exports.StoreApiRequestFactory = StoreApiRequestFactory; +var StoreApiResponseProcessor = (function () { + function StoreApiResponseProcessor() { + } + StoreApiResponseProcessor.prototype.deleteOrder = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + StoreApiResponseProcessor.prototype.getInventory = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "{ [key: string]: number; }"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + StoreApiResponseProcessor.prototype.getOrderById = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Order"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + StoreApiResponseProcessor.prototype.placeOrder = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Order"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + return StoreApiResponseProcessor; +}()); +exports.StoreApiResponseProcessor = StoreApiResponseProcessor; +//# sourceMappingURL=StoreApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map new file mode 100644 index 000000000000..fa6a50a5a57a --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StoreApi.js","sourceRoot":"","sources":["../../apis/StoreApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAE1E,+DAA4D;AAG5D;IAA4C,0CAAqB;IAAjE;;IAuHA,CAAC;IApHU,4CAAW,GAAlB,UAAmB,OAAe,EAAE,OAAa;QAE7C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,wBAAwB;aACrC,OAAO,CAAC,GAAG,GAAG,SAAS,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAG5E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAazG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAY,GAAnB,UAAoB,OAAa;QAGhC,IAAM,YAAY,GAAG,kBAAkB,CAAC;QAGxC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWzG,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAY,GAAnB,UAAoB,OAAe,EAAE,OAAa;QAE9C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,uBAAa,CAAC,6EAA6E,CAAC,CAAC;SAC1G;QAIJ,IAAM,YAAY,GAAG,wBAAwB;aACrC,OAAO,CAAC,GAAG,GAAG,SAAS,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAG5E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,2CAAU,GAAjB,UAAkB,KAAY,EAAE,OAAa;QAEzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,cAAc,CAAC;QAGpC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,OAAO,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC7H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACnG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,6BAAC;AAAD,CAAC,AAvHD,CAA4C,+BAAqB,GAuHhE;AAvHY,wDAAsB;AA6HnC;IAAA;IA2DA,CAAC;IArDU,+CAAW,GAAlB,UAAmB,QAAyB;QAC3C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,gDAAY,GAAnB,UAAoB,QAAyB;QAC5C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAA+B,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAA+B,CAAC;QACjJ,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,gDAAY,GAAnB,UAAoB,QAAyB;QAC5C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAU,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAU,CAAC;QAClF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,8CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAU,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAU,CAAC;QAClF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAEL,gCAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,8DAAyB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts new file mode 100644 index 000000000000..e8f92cc42357 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts @@ -0,0 +1,23 @@ +import { BaseAPIRequestFactory } from './baseapi'; +import { RequestContext, ResponseContext } from '../http/http'; +import { User } from '../models/User'; +export declare class UserApiRequestFactory extends BaseAPIRequestFactory { + createUser(user: User, options?: any): RequestContext; + createUsersWithArrayInput(user: Array, options?: any): RequestContext; + createUsersWithListInput(user: Array, options?: any): RequestContext; + deleteUser(username: string, options?: any): RequestContext; + getUserByName(username: string, options?: any): RequestContext; + loginUser(username: string, password: string, options?: any): RequestContext; + logoutUser(options?: any): RequestContext; + updateUser(username: string, user: User, options?: any): RequestContext; +} +export declare class UserApiResponseProcessor { + createUser(response: ResponseContext): void; + createUsersWithArrayInput(response: ResponseContext): void; + createUsersWithListInput(response: ResponseContext): void; + deleteUser(response: ResponseContext): void; + getUserByName(response: ResponseContext): User; + loginUser(response: ResponseContext): string; + logoutUser(response: ResponseContext): void; + updateUser(response: ResponseContext): void; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js new file mode 100644 index 000000000000..558ffdad15f3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js @@ -0,0 +1,181 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var baseapi_1 = require("./baseapi"); +var http_1 = require("../http/http"); +var ObjectSerializer_1 = require("../models/ObjectSerializer"); +var UserApiRequestFactory = (function (_super) { + __extends(UserApiRequestFactory, _super); + function UserApiRequestFactory() { + return _super !== null && _super.apply(this, arguments) || this; + } + UserApiRequestFactory.prototype.createUser = function (user, options) { + if (user === null || user === undefined) { + throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUser.'); + } + var localVarPath = '/user'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); + requestContext.setBody(serializedBody); + return requestContext; + }; + UserApiRequestFactory.prototype.createUsersWithArrayInput = function (user, options) { + if (user === null || user === undefined) { + throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + } + var localVarPath = '/user/createWithArray'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); + requestContext.setBody(serializedBody); + return requestContext; + }; + UserApiRequestFactory.prototype.createUsersWithListInput = function (user, options) { + if (user === null || user === undefined) { + throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + } + var localVarPath = '/user/createWithList'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); + requestContext.setBody(serializedBody); + return requestContext; + }; + UserApiRequestFactory.prototype.deleteUser = function (username, options) { + if (username === null || username === undefined) { + throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + var localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); + return requestContext; + }; + UserApiRequestFactory.prototype.getUserByName = function (username, options) { + if (username === null || username === undefined) { + throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + var localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + return requestContext; + }; + UserApiRequestFactory.prototype.loginUser = function (username, password, options) { + if (username === null || username === undefined) { + throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + if (password === null || password === undefined) { + throw new baseapi_1.RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + var localVarPath = '/user/login'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + if (username !== undefined) { + requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(username, "string")); + } + if (password !== undefined) { + requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(password, "string")); + } + return requestContext; + }; + UserApiRequestFactory.prototype.logoutUser = function (options) { + var localVarPath = '/user/logout'; + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); + return requestContext; + }; + UserApiRequestFactory.prototype.updateUser = function (username, user, options) { + if (username === null || username === undefined) { + throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + if (user === null || user === undefined) { + throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling updateUser.'); + } + var localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PUT); + requestContext.setHeaderParam("Content-Type", "application/json"); + var needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); + requestContext.setBody(serializedBody); + return requestContext; + }; + return UserApiRequestFactory; +}(baseapi_1.BaseAPIRequestFactory)); +exports.UserApiRequestFactory = UserApiRequestFactory; +var UserApiResponseProcessor = (function () { + function UserApiResponseProcessor() { + } + UserApiResponseProcessor.prototype.createUser = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + UserApiResponseProcessor.prototype.createUsersWithArrayInput = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + UserApiResponseProcessor.prototype.createUsersWithListInput = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + UserApiResponseProcessor.prototype.deleteUser = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + UserApiResponseProcessor.prototype.getUserByName = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "User"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + UserApiResponseProcessor.prototype.loginUser = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "string"); + if (responseOK) { + return body; + } + else { + throw body; + } + }; + UserApiResponseProcessor.prototype.logoutUser = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + UserApiResponseProcessor.prototype.updateUser = function (response) { + var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; + if (!responseOK) { + throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + } + }; + return UserApiResponseProcessor; +}()); +exports.UserApiResponseProcessor = UserApiResponseProcessor; +//# sourceMappingURL=UserApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map new file mode 100644 index 000000000000..de37ea2320f5 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserApi.js","sourceRoot":"","sources":["../../apis/UserApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAE1E,+DAA4D;AAG5D;IAA2C,yCAAqB;IAAhE;;IAiQA,CAAC;IA9PU,0CAAU,GAAjB,UAAkB,IAAU,EAAE,OAAa;QAEvC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,OAAO,CAAC;QAG7B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,MAAM,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC5H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yDAAyB,GAAhC,UAAiC,IAAiB,EAAE,OAAa;QAE7D,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,uFAAuF,CAAC,CAAC;SACpH;QAIJ,IAAM,YAAY,GAAG,uBAAuB,CAAC;QAG7C,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,mBAAmB,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QACzI,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wDAAwB,GAA/B,UAAgC,IAAiB,EAAE,OAAa;QAE5D,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,sFAAsF,CAAC,CAAC;SACnH;QAIJ,IAAM,YAAY,GAAG,sBAAsB,CAAC;QAG5C,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,mBAAmB,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QACzI,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,QAAgB,EAAE,OAAa;QAE7C,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAazG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAa,GAApB,UAAqB,QAAgB,EAAE,OAAa;QAEhD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,+EAA+E,CAAC,CAAC;SAC5G;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAS,GAAhB,UAAiB,QAAgB,EAAE,QAAgB,EAAE,OAAa;QAE9D,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,2EAA2E,CAAC,CAAC;SACxG;QAGD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,2EAA2E,CAAC,CAAC;SACxG;QAIJ,IAAM,YAAY,GAAG,aAAa,CAAC;QAGnC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjF;QACD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjF;QAWJ,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,OAAa;QAG9B,IAAM,YAAY,GAAG,cAAc,CAAC;QAGpC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,QAAgB,EAAE,IAAU,EAAE,OAAa;QAEzD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAGD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAUnG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,MAAM,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC5H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,4BAAC;AAAD,CAAC,AAjQD,CAA2C,+BAAqB,GAiQ/D;AAjQY,sDAAqB;AAuQlC;IAAA;IAwGA,CAAC;IAlGU,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,4DAAyB,GAAhC,UAAiC,QAAyB;QACzD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,2DAAwB,GAA/B,UAAgC,QAAyB;QACxD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,gDAAa,GAApB,UAAqB,QAAyB;QAC7C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAS,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAS,CAAC;QAC/E,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,4CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAW,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAW,CAAC;QACrF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAEL,+BAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4DAAwB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts new file mode 100644 index 000000000000..f819e9175de0 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts @@ -0,0 +1,16 @@ +import { Configuration } from '../configuration'; +export declare const COLLECTION_FORMATS: { + csv: string; + ssv: string; + tsv: string; + pipes: string; +}; +export declare class BaseAPIRequestFactory { + protected configuration: Configuration; + constructor(configuration: Configuration); +} +export declare class RequiredError extends Error { + field: string; + name: "RequiredError"; + constructor(field: string, msg?: string); +} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js new file mode 100644 index 000000000000..88edf23e013a --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js @@ -0,0 +1,41 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; +var BaseAPIRequestFactory = (function () { + function BaseAPIRequestFactory(configuration) { + this.configuration = configuration; + } + return BaseAPIRequestFactory; +}()); +exports.BaseAPIRequestFactory = BaseAPIRequestFactory; +; +var RequiredError = (function (_super) { + __extends(RequiredError, _super); + function RequiredError(field, msg) { + var _this = _super.call(this, msg) || this; + _this.field = field; + _this.name = "RequiredError"; + return _this; + } + return RequiredError; +}(Error)); +exports.RequiredError = RequiredError; +//# sourceMappingURL=baseapi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map new file mode 100644 index 000000000000..384b2bd789e4 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map @@ -0,0 +1 @@ +{"version":3,"file":"baseapi.js","sourceRoot":"","sources":["../../apis/baseapi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMa,QAAA,kBAAkB,GAAG;IAC9B,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,GAAG;CACb,CAAC;AAQF;IAEI,+BAAsB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAClD,CAAC;IACL,4BAAC;AAAD,CAAC,AAJD,IAIC;AAJY,sDAAqB;AAIjC,CAAC;AAQF;IAAmC,iCAAK;IAEpC,uBAAmB,KAAa,EAAE,GAAY;QAA9C,YACI,kBAAM,GAAG,CAAC,SACb;QAFkB,WAAK,GAAL,KAAK,CAAQ;QADhC,UAAI,GAAoB,eAAe,CAAC;;IAGxC,CAAC;IACL,oBAAC;AAAD,CAAC,AALD,CAAmC,KAAK,GAKvC;AALY,sCAAa"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts b/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts new file mode 100644 index 000000000000..0edccf0e3949 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts @@ -0,0 +1,43 @@ +import { RequestContext } from '../http/http'; +export declare abstract class SecurityAuthentication { + private name; + constructor(name: string); + getName(): string; + abstract applySecurityAuthentication(context: RequestContext): void; +} +export declare class NoAuthentication extends SecurityAuthentication { + constructor(); + applySecurityAuthentication(_context: RequestContext): void; +} +export declare class APIKeyAuthentication extends SecurityAuthentication { + private paramName; + private keyLocation; + private apiKey; + constructor(authName: string, paramName: string, keyLocation: "query" | "header" | "cookie", apiKey: string); + applySecurityAuthentication(context: RequestContext): void; +} +export declare class HttpBasicAuthentication extends SecurityAuthentication { + private username; + private password; + constructor(authName: string, username: string, password: string); + applySecurityAuthentication(context: RequestContext): void; +} +export declare class OAuth2Authentication extends SecurityAuthentication { + constructor(authName: string); + applySecurityAuthentication(context: RequestContext): void; +} +export declare type AuthMethods = { + "api_key"?: APIKeyAuthentication; + "petstore_auth"?: OAuth2Authentication; +}; +export declare type ApiKeyConfiguration = string; +export declare type HttpBasicConfiguration = { + "username": string; + "password": string; +}; +export declare type OAuth2Configuration = string; +export declare type AuthMethodsConfiguration = { + "api_key"?: ApiKeyConfiguration; + "petstore_auth"?: OAuth2Configuration; +}; +export declare function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods; diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js new file mode 100644 index 000000000000..20869b9d94ff --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js @@ -0,0 +1,99 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var btoa = require("btoa"); +var SecurityAuthentication = (function () { + function SecurityAuthentication(name) { + this.name = name; + } + SecurityAuthentication.prototype.getName = function () { + return this.name; + }; + return SecurityAuthentication; +}()); +exports.SecurityAuthentication = SecurityAuthentication; +var NoAuthentication = (function (_super) { + __extends(NoAuthentication, _super); + function NoAuthentication() { + return _super.call(this, "_no_auth") || this; + } + NoAuthentication.prototype.applySecurityAuthentication = function (_context) { + }; + return NoAuthentication; +}(SecurityAuthentication)); +exports.NoAuthentication = NoAuthentication; +var APIKeyAuthentication = (function (_super) { + __extends(APIKeyAuthentication, _super); + function APIKeyAuthentication(authName, paramName, keyLocation, apiKey) { + var _this = _super.call(this, authName) || this; + _this.paramName = paramName; + _this.keyLocation = keyLocation; + _this.apiKey = apiKey; + return _this; + } + APIKeyAuthentication.prototype.applySecurityAuthentication = function (context) { + if (this.keyLocation === "header") { + context.setHeaderParam(this.paramName, this.apiKey); + } + else if (this.keyLocation === "cookie") { + context.addCookie(this.paramName, this.apiKey); + } + else if (this.keyLocation === "query") { + context.setQueryParam(this.paramName, this.apiKey); + } + }; + return APIKeyAuthentication; +}(SecurityAuthentication)); +exports.APIKeyAuthentication = APIKeyAuthentication; +var HttpBasicAuthentication = (function (_super) { + __extends(HttpBasicAuthentication, _super); + function HttpBasicAuthentication(authName, username, password) { + var _this = _super.call(this, authName) || this; + _this.username = username; + _this.password = password; + return _this; + } + HttpBasicAuthentication.prototype.applySecurityAuthentication = function (context) { + var comb = this.username + ":" + this.password; + context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + }; + return HttpBasicAuthentication; +}(SecurityAuthentication)); +exports.HttpBasicAuthentication = HttpBasicAuthentication; +var OAuth2Authentication = (function (_super) { + __extends(OAuth2Authentication, _super); + function OAuth2Authentication(authName) { + return _super.call(this, authName) || this; + } + OAuth2Authentication.prototype.applySecurityAuthentication = function (context) { + }; + return OAuth2Authentication; +}(SecurityAuthentication)); +exports.OAuth2Authentication = OAuth2Authentication; +function configureAuthMethods(conf) { + var authMethods = {}; + if (!conf) { + return authMethods; + } + if (conf["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + } + if (conf["petstore_auth"]) { + authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); + } + return authMethods; +} +exports.configureAuthMethods = configureAuthMethods; +//# sourceMappingURL=auth.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map new file mode 100644 index 000000000000..68239cd59086 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map @@ -0,0 +1 @@ +{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../auth/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,2BAA6B;AAE7B;IAEC,gCAA2B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAEvC,CAAC;IAMM,wCAAO,GAAd;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAIF,6BAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBqB,wDAAsB;AAkB5C;IAAsC,oCAAsB;IAE3D;eACC,kBAAM,UAAU,CAAC;IAClB,CAAC;IAEM,sDAA2B,GAAlC,UAAmC,QAAwB;IAE3D,CAAC;IACF,uBAAC;AAAD,CAAC,AATD,CAAsC,sBAAsB,GAS3D;AATY,4CAAgB;AAW7B;IAA0C,wCAAsB;IAE/D,8BAAmB,QAAgB,EAAU,SAAiB,EAAU,WAA0C,EAAU,MAAc;QAA1I,YACC,kBAAM,QAAQ,CAAC,SACf;QAF4C,eAAS,GAAT,SAAS,CAAQ;QAAU,iBAAW,GAAX,WAAW,CAA+B;QAAU,YAAM,GAAN,MAAM,CAAQ;;IAE1I,CAAC;IAEM,0DAA2B,GAAlC,UAAmC,OAAuB;QACzD,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;YAClC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpD;aAAM,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;YACzC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SAC/C;aAAM,IAAI,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE;YACxC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACnD;IACF,CAAC;IACF,2BAAC;AAAD,CAAC,AAfD,CAA0C,sBAAsB,GAe/D;AAfY,oDAAoB;AAkBjC;IAA6C,2CAAsB;IAElE,iCAAmB,QAAgB,EAAU,QAAgB,EAAU,QAAgB;QAAvF,YACC,kBAAM,QAAQ,CAAC,SACf;QAF4C,cAAQ,GAAR,QAAQ,CAAQ;QAAU,cAAQ,GAAR,QAAQ,CAAQ;;IAEvF,CAAC;IAEM,6DAA2B,GAAlC,UAAmC,OAAuB;QACzD,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/C,OAAO,CAAC,cAAc,CAAC,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IACF,8BAAC;AAAD,CAAC,AAVD,CAA6C,sBAAsB,GAUlE;AAVY,0DAAuB;AAYpC;IAA0C,wCAAsB;IAC/D,8BAAmB,QAAgB;eAClC,kBAAM,QAAQ,CAAC;IAChB,CAAC;IAEM,0DAA2B,GAAlC,UAAmC,OAAuB;IAE1D,CAAC;IACF,2BAAC;AAAD,CAAC,AARD,CAA0C,sBAAsB,GAQ/D;AARY,oDAAoB;AAqBjC,SAAgB,oBAAoB,CAAC,IAA0C;IAC9E,IAAI,WAAW,GAAgB,EAC9B,CAAA;IAED,IAAI,CAAC,IAAI,EAAE;QACV,OAAO,WAAW,CAAC;KACnB;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE;QACpB,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,oBAAoB,CAAC,SAAS,EAAG,SAAS,EAAE,QAAQ,EAAW,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;KAC7G;IAED,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE;QAC1B,WAAW,CAAC,eAAe,CAAC,GAAG,IAAI,oBAAoB,CAAC,eAAe,CAAC,CAAC;KACzE;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAjBD,oDAiBC"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts b/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts new file mode 100644 index 000000000000..85f2ac938130 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts @@ -0,0 +1,17 @@ +import { HttpLibrary } from './http/http'; +import { Middleware } from './middleware'; +import { ServerConfiguration } from './servers'; +import { AuthMethods, AuthMethodsConfiguration } from './auth/auth'; +export interface ConfigurationParameters { + baseServer?: ServerConfiguration; + httpApi?: HttpLibrary; + middleware?: Middleware[]; + authMethods?: AuthMethodsConfiguration; +} +export declare class Configuration { + baseServer: ServerConfiguration; + httpApi: HttpLibrary; + middleware: Middleware[]; + authMethods: AuthMethods; + constructor(conf?: ConfigurationParameters); +} diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.js b/samples/client/petstore/typescript/builds/default/dist/configuration.js new file mode 100644 index 000000000000..404f626ac919 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/configuration.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var isomorphic_fetch_1 = require("./http/isomorphic-fetch"); +var servers_1 = require("./servers"); +var auth_1 = require("./auth/auth"); +var Configuration = (function () { + function Configuration(conf) { + if (conf === void 0) { conf = {}; } + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers_1.servers[0]; + this.httpApi = conf.httpApi || new isomorphic_fetch_1.IsomorphicFetchHttpLibrary(); + this.middleware = conf.middleware || []; + this.authMethods = auth_1.configureAuthMethods(conf.authMethods); + } + return Configuration; +}()); +exports.Configuration = Configuration; +//# sourceMappingURL=configuration.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.js.map b/samples/client/petstore/typescript/builds/default/dist/configuration.js.map new file mode 100644 index 000000000000..346874cb8154 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/configuration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../configuration.ts"],"names":[],"mappings":";;AAEA,4DAAmE;AACnE,qCAAuD;AACvD,oCAAwF;AAUxF;IAOI,uBAAY,IAAkC;QAAlC,qBAAA,EAAA,SAAkC;QAC1C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAO,CAAC,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,6CAA0B,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,2BAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IACL,oBAAC;AAAD,CAAC,AAbD,IAaC;AAbY,sCAAa"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts b/samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js new file mode 100644 index 000000000000..bb4728734413 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js @@ -0,0 +1,2 @@ +"use strict"; +//# sourceMappingURL=api.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map new file mode 100644 index 000000000000..05a42e6f2602 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map @@ -0,0 +1 @@ +{"version":3,"file":"api.js","sourceRoot":"","sources":["../../fetch/api.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts b/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts new file mode 100644 index 000000000000..00a823a23859 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts @@ -0,0 +1,50 @@ +import * as FormData from "form-data"; +export declare enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} +export interface FormEntry { + contentDisposition: string; + value: string | Blob; +} +export declare class HttpException extends Error { + constructor(msg: string); +} +export declare class RequestContext { + private httpMethod; + private headers; + private body; + private url; + constructor(url: string, httpMethod: HttpMethod); + getUrl(): string; + setUrl(url: string): void; + setBody(body: string | FormData): void; + getHttpMethod(): HttpMethod; + getHeaders(): { + [key: string]: string; + }; + getBody(): string | FormData; + setQueryParam(name: string, value: string): void; + addCookie(name: string, value: string): void; + setHeaderParam(key: string, value: string): void; +} +export declare class ResponseContext { + httpStatusCode: number; + headers: { + [key: string]: string; + }; + body: string; + constructor(httpStatusCode: number, headers: { + [key: string]: string; + }, body: string); +} +export interface HttpLibrary { + send(request: RequestContext): Promise; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.js b/samples/client/petstore/typescript/builds/default/dist/http/http.js new file mode 100644 index 000000000000..9cf226eb4ba0 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/http.js @@ -0,0 +1,91 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var URLParse = require("url-parse"); +var HttpMethod; +(function (HttpMethod) { + HttpMethod["GET"] = "GET"; + HttpMethod["HEAD"] = "HEAD"; + HttpMethod["POST"] = "POST"; + HttpMethod["PUT"] = "PUT"; + HttpMethod["DELETE"] = "DELETE"; + HttpMethod["CONNECT"] = "CONNECT"; + HttpMethod["OPTIONS"] = "OPTIONS"; + HttpMethod["TRACE"] = "TRACE"; + HttpMethod["PATCH"] = "PATCH"; +})(HttpMethod = exports.HttpMethod || (exports.HttpMethod = {})); +var HttpException = (function (_super) { + __extends(HttpException, _super); + function HttpException(msg) { + return _super.call(this, msg) || this; + } + return HttpException; +}(Error)); +exports.HttpException = HttpException; +var RequestContext = (function () { + function RequestContext(url, httpMethod) { + this.httpMethod = httpMethod; + this.headers = {}; + this.body = ""; + this.url = URLParse(url, true); + } + RequestContext.prototype.getUrl = function () { + return this.url.toString(); + }; + RequestContext.prototype.setUrl = function (url) { + this.url = URLParse(url, true); + }; + RequestContext.prototype.setBody = function (body) { + if (this.httpMethod === HttpMethod.GET) { + throw new HttpException("Body should not be included in GET-Requests!"); + } + this.body = body; + }; + RequestContext.prototype.getHttpMethod = function () { + return this.httpMethod; + }; + RequestContext.prototype.getHeaders = function () { + return this.headers; + }; + RequestContext.prototype.getBody = function () { + return this.body; + }; + RequestContext.prototype.setQueryParam = function (name, value) { + var queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + }; + RequestContext.prototype.addCookie = function (name, value) { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + }; + RequestContext.prototype.setHeaderParam = function (key, value) { + this.headers[key] = value; + }; + return RequestContext; +}()); +exports.RequestContext = RequestContext; +var ResponseContext = (function () { + function ResponseContext(httpStatusCode, headers, body) { + this.httpStatusCode = httpStatusCode; + this.headers = headers; + this.body = body; + } + return ResponseContext; +}()); +exports.ResponseContext = ResponseContext; +//# sourceMappingURL=http.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.js.map b/samples/client/petstore/typescript/builds/default/dist/http/http.js.map new file mode 100644 index 000000000000..9d17a13734c8 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/http.js.map @@ -0,0 +1 @@ +{"version":3,"file":"http.js","sourceRoot":"","sources":["../../http/http.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,oCAAsC;AAEtC,IAAY,UAUX;AAVD,WAAY,UAAU;IAClB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IACf,6BAAe,CAAA;AACnB,CAAC,EAVW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAUrB;AAQD;IAAmC,iCAAK;IACpC,uBAAmB,GAAW;eAC1B,kBAAM,GAAG,CAAC;IACd,CAAC;IACL,oBAAC;AAAD,CAAC,AAJD,CAAmC,KAAK,GAIvC;AAJY,sCAAa;AAM1B;IAKI,wBAAmB,GAAW,EAAU,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAJtD,YAAO,GAA8B,EAAE,CAAC;QACxC,SAAI,GAAsB,EAAE,CAAC;QAIjC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAEM,+BAAM,GAAb;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAEM,+BAAM,GAAb,UAAc,GAAW;QACxB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAGM,gCAAO,GAAd,UAAe,IAAuB;QAElC,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,CAAC,GAAG,EAAE;YACpC,MAAM,IAAI,aAAa,CAAC,8CAA8C,CAAC,CAAC;SAC3E;QAKD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAErB,CAAC;IAEM,sCAAa,GAApB;QACC,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,mCAAU,GAAjB;QACC,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,gCAAO,GAAd;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEG,sCAAa,GAApB,UAAqB,IAAY,EAAE,KAAa;QACzC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAEM,kCAAS,GAAhB,UAAiB,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;IACxD,CAAC;IAEM,uCAAc,GAArB,UAAsB,GAAW,EAAE,KAAa;QAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IACL,qBAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,wCAAc;AA6D3B;IAEI,yBAA0B,cAAsB,EACrC,OAAkC,EAAS,IAAY;QADxC,mBAAc,GAAd,cAAc,CAAQ;QACrC,YAAO,GAAP,OAAO,CAA2B;QAAS,SAAI,GAAJ,IAAI,CAAQ;IAClE,CAAC;IAEL,sBAAC;AAAD,CAAC,AAND,IAMC;AANY,0CAAe"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts new file mode 100644 index 000000000000..f19b66c9ed3b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts @@ -0,0 +1,5 @@ +import { HttpLibrary, RequestContext, ResponseContext } from './http'; +import 'isomorphic-fetch'; +export declare class IsomorphicFetchHttpLibrary implements HttpLibrary { + send(request: RequestContext): Promise; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js new file mode 100644 index 000000000000..26b39b311e9a --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var http_1 = require("./http"); +var e6p = require("es6-promise"); +e6p.polyfill(); +require("isomorphic-fetch"); +var IsomorphicFetchHttpLibrary = (function () { + function IsomorphicFetchHttpLibrary() { + } + IsomorphicFetchHttpLibrary.prototype.send = function (request) { + var method = request.getHttpMethod().toString(); + var body = request.getBody(); + return fetch(request.getUrl(), { + method: method, + body: body, + headers: request.getHeaders(), + credentials: "same-origin" + }).then(function (resp) { + var headers = resp.headers._headers; + for (var key in headers) { + headers[key] = headers[key].join("; "); + } + return resp.text().then(function (body) { + return new http_1.ResponseContext(resp.status, headers, body); + }); + }); + }; + return IsomorphicFetchHttpLibrary; +}()); +exports.IsomorphicFetchHttpLibrary = IsomorphicFetchHttpLibrary; +//# sourceMappingURL=isomorphic-fetch.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map new file mode 100644 index 000000000000..4b5d3e858522 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isomorphic-fetch.js","sourceRoot":"","sources":["../../http/isomorphic-fetch.ts"],"names":[],"mappings":";;AAAA,+BAAoE;AACpE,iCAAkC;AAClC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACf,4BAA0B;AAE1B;IAAA;IAwBA,CAAC;IAtBU,yCAAI,GAAX,UAAY,OAAuB;QAC/B,IAAI,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;YAC3B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAW;YACjB,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;YAC7B,WAAW,EAAE,aAAa;SAC7B,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YAET,IAAI,OAAO,GAAI,IAAI,CAAC,OAAe,CAAC,QAAQ,CAAC;YAC7C,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;gBACrB,OAAO,CAAC,GAAG,CAAC,GAAI,OAAO,CAAC,GAAG,CAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC7D;YAED,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAC,IAAI;gBACzB,OAAO,IAAI,sBAAe,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;YAC1D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IAEP,CAAC;IACL,iCAAC;AAAD,CAAC,AAxBD,IAwBC;AAxBY,gEAA0B"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/index.d.ts b/samples/client/petstore/typescript/builds/default/dist/index.d.ts new file mode 100644 index 000000000000..e9fa76f6079f --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/index.d.ts @@ -0,0 +1,6 @@ +export * from './configuration'; +export * from './http/http'; +export * from './auth/auth'; +export * from './middleware'; +export * from './servers'; +export * from './http/isomorphic-fetch'; diff --git a/samples/client/petstore/typescript/builds/default/dist/index.js b/samples/client/petstore/typescript/builds/default/dist/index.js new file mode 100644 index 000000000000..e3bfaf4d3544 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/index.js @@ -0,0 +1,11 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./configuration")); +__export(require("./http/http")); +__export(require("./auth/auth")); +__export(require("./servers")); +__export(require("./http/isomorphic-fetch")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/index.js.map b/samples/client/petstore/typescript/builds/default/dist/index.js.map new file mode 100644 index 000000000000..0ac7879e10dd --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+B;AAC/B,iCAA4B;AAC5B,iCAA4B;AAE5B,+BAA0B;AAI1B,6CAAwC"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts b/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts new file mode 100644 index 000000000000..f8c719e0b389 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts @@ -0,0 +1,5 @@ +import { RequestContext, ResponseContext } from './http/http'; +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.js b/samples/client/petstore/typescript/builds/default/dist/middleware.js new file mode 100644 index 000000000000..f83bf79d25c6 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/middleware.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=middleware.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.js.map b/samples/client/petstore/typescript/builds/default/dist/middleware.js.map new file mode 100644 index 000000000000..71e436453e0b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/middleware.js.map @@ -0,0 +1 @@ +{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../middleware.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts new file mode 100644 index 000000000000..8d0cd97507dc --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts @@ -0,0 +1,16 @@ +export declare class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js new file mode 100644 index 000000000000..0ef210da7882 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ApiResponse = (function () { + function ApiResponse() { + } + ApiResponse.getAttributeTypeMap = function () { + return ApiResponse.attributeTypeMap; + }; + ApiResponse.discriminator = undefined; + ApiResponse.attributeTypeMap = [ + { + "name": "code", + "baseName": "code", + "type": "number" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + }, + { + "name": "message", + "baseName": "message", + "type": "string" + } + ]; + return ApiResponse; +}()); +exports.ApiResponse = ApiResponse; +//# sourceMappingURL=ApiResponse.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map new file mode 100644 index 000000000000..666330d7e2ce --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ApiResponse.js","sourceRoot":"","sources":["../../models/ApiResponse.ts"],"names":[],"mappings":";;AAOA;IAAA;IA2BA,CAAC;IAHU,+BAAmB,GAA1B;QACI,OAAO,WAAW,CAAC,gBAAgB,CAAC;IACxC,CAAC;IArBM,yBAAa,GAAuB,SAAS,CAAC;IAE9C,4BAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,SAAS;YACrB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,kBAAC;CAAA,AA3BD,IA2BC;AA3BY,kCAAW"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts new file mode 100644 index 000000000000..727a8ab12aff --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts @@ -0,0 +1,15 @@ +export declare class Category { + 'id'?: number; + 'name'?: string; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.js b/samples/client/petstore/typescript/builds/default/dist/models/Category.js new file mode 100644 index 000000000000..1afdb16f0144 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Category.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Category = (function () { + function Category() { + } + Category.getAttributeTypeMap = function () { + return Category.attributeTypeMap; + }; + Category.discriminator = undefined; + Category.attributeTypeMap = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } + ]; + return Category; +}()); +exports.Category = Category; +//# sourceMappingURL=Category.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map new file mode 100644 index 000000000000..8906be35442c --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../models/Category.ts"],"names":[],"mappings":";;AAOA;IAAA;IAqBA,CAAC;IAHU,4BAAmB,GAA1B;QACI,OAAO,QAAQ,CAAC,gBAAgB,CAAC;IACrC,CAAC;IAhBM,sBAAa,GAAuB,SAAS,CAAC;IAE9C,yBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,eAAC;CAAA,AArBD,IAqBC;AArBY,4BAAQ"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts new file mode 100644 index 000000000000..cdf77055ed1e --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts @@ -0,0 +1,11 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; +export declare class ObjectSerializer { + static findCorrectType(data: any, expectedType: string): any; + static serialize(data: any, type: string): any; + static deserialize(data: any, type: string): any; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js new file mode 100644 index 000000000000..a5c516ae0ecd --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js @@ -0,0 +1,157 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./ApiResponse")); +__export(require("./Category")); +__export(require("./Order")); +__export(require("./Pet")); +__export(require("./Tag")); +__export(require("./User")); +var ApiResponse_1 = require("./ApiResponse"); +var Category_1 = require("./Category"); +var Order_1 = require("./Order"); +var Pet_1 = require("./Pet"); +var Tag_1 = require("./Tag"); +var User_1 = require("./User"); +var primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" +]; +var enumsMap = { + "Order.StatusEnum": Order_1.Order.StatusEnum, + "Pet.StatusEnum": Pet_1.Pet.StatusEnum, +}; +var typeMap = { + "ApiResponse": ApiResponse_1.ApiResponse, + "Category": Category_1.Category, + "Order": Order_1.Order, + "Pet": Pet_1.Pet, + "Tag": Tag_1.Tag, + "User": User_1.User, +}; +var ObjectSerializer = (function () { + function ObjectSerializer() { + } + ObjectSerializer.findCorrectType = function (data, expectedType) { + if (data == undefined) { + return expectedType; + } + else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } + else if (expectedType === "Date") { + return expectedType; + } + else { + if (enumsMap[expectedType]) { + return expectedType; + } + if (!typeMap[expectedType]) { + return expectedType; + } + var discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; + } + else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if (typeMap[discriminatorType]) { + return discriminatorType; + } + else { + return expectedType; + } + } + else { + return expectedType; + } + } + } + }; + ObjectSerializer.serialize = function (data, type) { + if (data == undefined) { + return data; + } + else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } + else if (type.lastIndexOf("Array<", 0) === 0) { + var subType = type.replace("Array<", ""); + subType = subType.substring(0, subType.length - 1); + var transformedData = []; + for (var index in data) { + var date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } + else if (type === "Date") { + return data.toISOString(); + } + else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { + return data; + } + type = this.findCorrectType(data, type); + var attributeTypes = typeMap[type].getAttributeTypeMap(); + var instance = {}; + for (var index in attributeTypes) { + var attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + }; + ObjectSerializer.deserialize = function (data, type) { + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } + else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } + else if (type.lastIndexOf("Array<", 0) === 0) { + var subType = type.replace("Array<", ""); + subType = subType.substring(0, subType.length - 1); + var transformedData = []; + for (var index in data) { + var date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } + else if (type === "Date") { + return new Date(data); + } + else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { + return data; + } + var instance = new typeMap[type](); + var attributeTypes = typeMap[type].getAttributeTypeMap(); + for (var index in attributeTypes) { + var attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + }; + return ObjectSerializer; +}()); +exports.ObjectSerializer = ObjectSerializer; +//# sourceMappingURL=ObjectSerializer.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map new file mode 100644 index 000000000000..3adedc52634b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ObjectSerializer.js","sourceRoot":"","sources":["../../models/ObjectSerializer.ts"],"names":[],"mappings":";;;;;AAAA,mCAA8B;AAC9B,gCAA2B;AAC3B,6BAAwB;AACxB,2BAAsB;AACtB,2BAAsB;AACtB,4BAAuB;AAEvB,6CAA4C;AAC5C,uCAAsC;AACtC,iCAAgC;AAChC,6BAA4B;AAC5B,6BAA4B;AAC5B,+BAA8B;AAG9B,IAAI,UAAU,GAAG;IACG,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;IACP,QAAQ;IACR,KAAK;CACP,CAAC;AAEnB,IAAI,QAAQ,GAA2B;IAC/B,kBAAkB,EAAE,aAAK,CAAC,UAAU;IACpC,gBAAgB,EAAE,SAAG,CAAC,UAAU;CACvC,CAAA;AAED,IAAI,OAAO,GAA2B;IAClC,aAAa,EAAE,yBAAW;IAC1B,UAAU,EAAE,mBAAQ;IACpB,OAAO,EAAE,aAAK;IACd,KAAK,EAAE,SAAG;IACV,KAAK,EAAE,SAAG;IACV,MAAM,EAAE,WAAI;CACf,CAAA;AAED;IAAA;IA6GA,CAAC;IA5GiB,gCAAe,GAA7B,UAA8B,IAAS,EAAE,YAAoB;QACzD,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,YAAY,CAAC;SACvB;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YAC9D,OAAO,YAAY,CAAC;SACvB;aAAM,IAAI,YAAY,KAAK,MAAM,EAAE;YAChC,OAAO,YAAY,CAAC;SACvB;aAAM;YACH,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE;gBACxB,OAAO,YAAY,CAAC;aACvB;YAED,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;gBACxB,OAAO,YAAY,CAAC;aACvB;YAGD,IAAI,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC;YAChE,IAAI,qBAAqB,IAAI,IAAI,EAAE;gBAC/B,OAAO,YAAY,CAAC;aACvB;iBAAM;gBACH,IAAI,IAAI,CAAC,qBAAqB,CAAC,EAAE;oBAC7B,IAAI,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC;oBACpD,IAAG,OAAO,CAAC,iBAAiB,CAAC,EAAC;wBAC1B,OAAO,iBAAiB,CAAC;qBAC5B;yBAAM;wBACH,OAAO,YAAY,CAAC;qBACvB;iBACJ;qBAAM;oBACH,OAAO,YAAY,CAAC;iBACvB;aACJ;SACJ;IACL,CAAC;IAEa,0BAAS,GAAvB,UAAwB,IAAS,EAAE,IAAY;QAC3C,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YAC5C,IAAI,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,eAAe,GAAU,EAAE,CAAC;YAChC,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE;gBACpB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;aACnE;YACD,OAAO,eAAe,CAAC;SAC1B;aAAM,IAAI,IAAI,KAAK,MAAM,EAAE;YACxB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;aAAM;YACH,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YAGD,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAGxC,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;YACzD,IAAI,QAAQ,GAA2B,EAAE,CAAC;YAC1C,KAAK,IAAI,KAAK,IAAI,cAAc,EAAE;gBAC9B,IAAI,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBAC1C,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC/G;YACD,OAAO,QAAQ,CAAC;SACnB;IACL,CAAC;IAEa,4BAAW,GAAzB,UAA0B,IAAS,EAAE,IAAY;QAE7C,IAAI,GAAG,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YAC5C,IAAI,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,eAAe,GAAU,EAAE,CAAC;YAChC,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE;gBACpB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;aACrE;YACD,OAAO,eAAe,CAAC;SAC1B;aAAM,IAAI,IAAI,KAAK,MAAM,EAAE;YACxB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;aAAM;YACH,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,QAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;YACzD,KAAK,IAAI,KAAK,IAAI,cAAc,EAAE;gBAC9B,IAAI,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBAC1C,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aACjH;YACD,OAAO,QAAQ,CAAC;SACnB;IACL,CAAC;IACL,uBAAC;AAAD,CAAC,AA7GD,IA6GC;AA7GY,4CAAgB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts new file mode 100644 index 000000000000..49771cf1b5b7 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts @@ -0,0 +1,26 @@ +export declare class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; + 'status'?: Order.StatusEnum; + 'complete'?: boolean; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} +export declare namespace Order { + enum StatusEnum { + Placed, + Approved, + Delivered + } +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.js b/samples/client/petstore/typescript/builds/default/dist/models/Order.js new file mode 100644 index 000000000000..ff531f4ff002 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Order.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Order = (function () { + function Order() { + } + Order.getAttributeTypeMap = function () { + return Order.attributeTypeMap; + }; + Order.discriminator = undefined; + Order.attributeTypeMap = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date" + }, + { + "name": "status", + "baseName": "status", + "type": "Order.StatusEnum" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean" + } + ]; + return Order; +}()); +exports.Order = Order; +(function (Order) { + var StatusEnum; + (function (StatusEnum) { + StatusEnum[StatusEnum["Placed"] = 'placed'] = "Placed"; + StatusEnum[StatusEnum["Approved"] = 'approved'] = "Approved"; + StatusEnum[StatusEnum["Delivered"] = 'delivered'] = "Delivered"; + })(StatusEnum = Order.StatusEnum || (Order.StatusEnum = {})); +})(Order = exports.Order || (exports.Order = {})); +exports.Order = Order; +//# sourceMappingURL=Order.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map new file mode 100644 index 000000000000..6e0842825dbe --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Order.js","sourceRoot":"","sources":["../../models/Order.ts"],"names":[],"mappings":";;AAOA;IAAA;IAgDA,CAAC;IAHU,yBAAmB,GAA1B;QACI,OAAO,KAAK,CAAC,gBAAgB,CAAC;IAClC,CAAC;IApCM,mBAAa,GAAuB,SAAS,CAAC;IAE9C,sBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,MAAM;SACjB;QACD;YACI,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,kBAAkB;SAC7B;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,SAAS;SACpB;KAAK,CAAC;IAKf,YAAC;CAAA,AAhDD,IAgDC;AAhDY,sBAAK;AAkDlB,WAAiB,KAAK;IAClB,IAAY,UAIX;IAJD,WAAY,UAAU;QAClB,kCAAe,QAAQ,YAAA,CAAA;QACvB,oCAAiB,UAAU,cAAA,CAAA;QAC3B,qCAAkB,WAAW,eAAA,CAAA;IACjC,CAAC,EAJW,UAAU,GAAV,gBAAU,KAAV,gBAAU,QAIrB;AACL,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAMrB;AAxDY,sBAAK"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts new file mode 100644 index 000000000000..1d2a7e3fc0a0 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts @@ -0,0 +1,28 @@ +import { Category } from './Category'; +import { Tag } from './Tag'; +export declare class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; + 'status'?: Pet.StatusEnum; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} +export declare namespace Pet { + enum StatusEnum { + Available, + Pending, + Sold + } +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js new file mode 100644 index 000000000000..9fb032b04e30 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Pet = (function () { + function Pet() { + } + Pet.getAttributeTypeMap = function () { + return Pet.attributeTypeMap; + }; + Pet.discriminator = undefined; + Pet.attributeTypeMap = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "category", + "baseName": "category", + "type": "Category" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array" + }, + { + "name": "status", + "baseName": "status", + "type": "Pet.StatusEnum" + } + ]; + return Pet; +}()); +exports.Pet = Pet; +(function (Pet) { + var StatusEnum; + (function (StatusEnum) { + StatusEnum[StatusEnum["Available"] = 'available'] = "Available"; + StatusEnum[StatusEnum["Pending"] = 'pending'] = "Pending"; + StatusEnum[StatusEnum["Sold"] = 'sold'] = "Sold"; + })(StatusEnum = Pet.StatusEnum || (Pet.StatusEnum = {})); +})(Pet = exports.Pet || (exports.Pet = {})); +exports.Pet = Pet; +//# sourceMappingURL=Pet.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map new file mode 100644 index 000000000000..fb14e0801b53 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Pet.js","sourceRoot":"","sources":["../../models/Pet.ts"],"names":[],"mappings":";;AASA;IAAA;IAgDA,CAAC;IAHU,uBAAmB,GAA1B;QACI,OAAO,GAAG,CAAC,gBAAgB,CAAC;IAChC,CAAC;IApCM,iBAAa,GAAuB,SAAS,CAAC;IAE9C,oBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,UAAU;SACrB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,eAAe;SAC1B;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,YAAY;SACvB;QACD;YACI,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,gBAAgB;SAC3B;KAAK,CAAC;IAKf,UAAC;CAAA,AAhDD,IAgDC;AAhDY,kBAAG;AAkDhB,WAAiB,GAAG;IAChB,IAAY,UAIX;IAJD,WAAY,UAAU;QAClB,qCAAkB,WAAW,eAAA,CAAA;QAC7B,mCAAgB,SAAS,aAAA,CAAA;QACzB,gCAAa,MAAM,UAAA,CAAA;IACvB,CAAC,EAJW,UAAU,GAAV,cAAU,KAAV,cAAU,QAIrB;AACL,CAAC,EANgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAMnB;AAxDY,kBAAG"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts new file mode 100644 index 000000000000..67bc2920f9dd --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts @@ -0,0 +1,15 @@ +export declare class Tag { + 'id'?: number; + 'name'?: string; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js new file mode 100644 index 000000000000..87e09817f366 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Tag = (function () { + function Tag() { + } + Tag.getAttributeTypeMap = function () { + return Tag.attributeTypeMap; + }; + Tag.discriminator = undefined; + Tag.attributeTypeMap = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } + ]; + return Tag; +}()); +exports.Tag = Tag; +//# sourceMappingURL=Tag.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map new file mode 100644 index 000000000000..03ee391c2a2d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../models/Tag.ts"],"names":[],"mappings":";;AAOA;IAAA;IAqBA,CAAC;IAHU,uBAAmB,GAA1B;QACI,OAAO,GAAG,CAAC,gBAAgB,CAAC;IAChC,CAAC;IAhBM,iBAAa,GAAuB,SAAS,CAAC;IAE9C,oBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,UAAC;CAAA,AArBD,IAqBC;AArBY,kBAAG"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts new file mode 100644 index 000000000000..6bad8680ad29 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts @@ -0,0 +1,21 @@ +export declare class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; + 'userStatus'?: number; + static discriminator: string | undefined; + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + }[]; +} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.js b/samples/client/petstore/typescript/builds/default/dist/models/User.js new file mode 100644 index 000000000000..a2d431b5e89d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/User.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var User = (function () { + function User() { + } + User.getAttributeTypeMap = function () { + return User.attributeTypeMap; + }; + User.discriminator = undefined; + User.attributeTypeMap = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "username", + "baseName": "username", + "type": "string" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "password", + "baseName": "password", + "type": "string" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number" + } + ]; + return User; +}()); +exports.User = User; +//# sourceMappingURL=User.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.js.map b/samples/client/petstore/typescript/builds/default/dist/models/User.js.map new file mode 100644 index 000000000000..3bb95d7da848 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/models/User.js.map @@ -0,0 +1 @@ +{"version":3,"file":"User.js","sourceRoot":"","sources":["../../models/User.ts"],"names":[],"mappings":";;AAOA;IAAA;IA4DA,CAAC;IAHU,wBAAmB,GAA1B;QACI,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IA9CM,kBAAa,GAAuB,SAAS,CAAC;IAE9C,qBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,YAAY;YACpB,UAAU,EAAE,YAAY;YACxB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,WAAC;CAAA,AA5DD,IA4DC;AA5DY,oBAAI"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.d.ts b/samples/client/petstore/typescript/builds/default/dist/servers.d.ts new file mode 100644 index 000000000000..4b73dab5d806 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/servers.d.ts @@ -0,0 +1,7 @@ +import { RequestContext, HttpMethod } from './http/http'; +export declare class ServerConfiguration { + private url; + constructor(url: string); + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} +export declare const servers: ServerConfiguration[]; diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.js b/samples/client/petstore/typescript/builds/default/dist/servers.js new file mode 100644 index 000000000000..8ed43ec5a3c5 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/servers.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var http_1 = require("./http/http"); +var ServerConfiguration = (function () { + function ServerConfiguration(url) { + this.url = url; + } + ServerConfiguration.prototype.makeRequestContext = function (endpoint, httpMethod) { + return new http_1.RequestContext(this.url + endpoint, httpMethod); + }; + return ServerConfiguration; +}()); +exports.ServerConfiguration = ServerConfiguration; +exports.servers = [ + new ServerConfiguration("http://petstore.swagger.io/v2"), +]; +//# sourceMappingURL=servers.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.js.map b/samples/client/petstore/typescript/builds/default/dist/servers.js.map new file mode 100644 index 000000000000..25d3c604ee57 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/dist/servers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"servers.js","sourceRoot":"","sources":["../servers.ts"],"names":[],"mappings":";;AAAA,oCAAuD;AAEvD;IAEI,6BAA2B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IACtC,CAAC;IAEG,gDAAkB,GAAzB,UAA0B,QAAgB,EAAE,UAAsB;QACjE,OAAO,IAAI,qBAAc,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IACF,0BAAC;AAAD,CAAC,AARD,IAQC;AARY,kDAAmB;AAUnB,QAAA,OAAO,GAAG;IACtB,IAAI,mBAAmB,CAAC,+BAA+B,CAAC;CACxD,CAAA"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 793b68f75e8e..cc4e4d7d1a30 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -1,6 +1,8 @@ /* TODO: LICENSE INFO */ +import { Category } from './Category'; +import { Tag } from './Tag'; /** * A pet for sale in the pet store diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json new file mode 100644 index 000000000000..6e51be4ad1cc --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -0,0 +1,468 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", + "dev": true + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" + }, + "@types/mocha": { + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", + "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", + "dev": true + }, + "@types/node": { + "version": "10.11.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.7.tgz", + "integrity": "sha512-yOxFfkN9xUFLyvWaeYj90mlqTJ41CsQzWKS3gXdOMOyPVacUsymejKxJ4/pMW7exouubuEeZLJawGgcNGYlTeg==" + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "es6-promise": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "dev": true + }, + "mime-db": { + "version": "1.36.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + }, + "mime-types": { + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "requires": { + "mime-db": "~1.36.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "querystringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", + "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "ts-node": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "url-parse": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", + "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", + "requires": { + "querystringify": "^2.0.0", + "requires-port": "^1.0.0" + } + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", + "dev": true + } + } +} diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json index 4ef0a0278025..142f3fa631a3 100644 --- a/samples/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -7,8 +7,8 @@ "declaration": true, /* Additional Checks */ - "noUnusedLocals": true, /* Report errors on unused locals. */ - "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ @@ -16,10 +16,10 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "declaration": true, "lib": [ "es6", "dom" ] }, "exclude": [ + "dist", "node_modules" ], "filesGlob": [ From e40d94984f68cba684c1ca4d7cbe611fd51de012 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 17 Oct 2018 16:38:08 +0200 Subject: [PATCH 12/85] Implemented fetch client --- .../languages/TypeScriptClientCodegen.java | 3 + .../generators/fetch/fetch.mustache | 57 +++-- .../typescript/http/isomorphic-fetch.mustache | 3 +- .../resources/typescript/models_all.mustache | 5 + .../petstore/typescript/builds/default/api.ts | 218 ++++++++++++++++ .../builds/default/dist/apis/PetApi.d.ts | 24 -- .../builds/default/dist/apis/PetApi.js | 237 ------------------ .../builds/default/dist/apis/PetApi.js.map | 1 - .../builds/default/dist/apis/StoreApi.d.ts | 17 -- .../builds/default/dist/apis/StoreApi.js | 109 -------- .../builds/default/dist/apis/StoreApi.js.map | 1 - .../builds/default/dist/apis/UserApi.d.ts | 23 -- .../builds/default/dist/apis/UserApi.js | 181 ------------- .../builds/default/dist/apis/UserApi.js.map | 1 - .../builds/default/dist/apis/baseapi.d.ts | 16 -- .../builds/default/dist/apis/baseapi.js | 41 --- .../builds/default/dist/apis/baseapi.js.map | 1 - .../builds/default/dist/auth/auth.d.ts | 43 ---- .../builds/default/dist/auth/auth.js | 99 -------- .../builds/default/dist/auth/auth.js.map | 1 - .../builds/default/dist/configuration.d.ts | 17 -- .../builds/default/dist/configuration.js | 17 -- .../builds/default/dist/configuration.js.map | 1 - .../builds/default/dist/fetch/api.d.ts | 0 .../builds/default/dist/fetch/api.js | 2 - .../builds/default/dist/fetch/api.js.map | 1 - .../builds/default/dist/http/http.d.ts | 50 ---- .../builds/default/dist/http/http.js | 91 ------- .../builds/default/dist/http/http.js.map | 1 - .../default/dist/http/isomorphic-fetch.d.ts | 5 - .../default/dist/http/isomorphic-fetch.js | 31 --- .../default/dist/http/isomorphic-fetch.js.map | 1 - .../typescript/builds/default/dist/index.d.ts | 6 - .../typescript/builds/default/dist/index.js | 11 - .../builds/default/dist/index.js.map | 1 - .../builds/default/dist/middleware.d.ts | 5 - .../builds/default/dist/middleware.js | 3 - .../builds/default/dist/middleware.js.map | 1 - .../default/dist/models/ApiResponse.d.ts | 16 -- .../builds/default/dist/models/ApiResponse.js | 30 --- .../default/dist/models/ApiResponse.js.map | 1 - .../builds/default/dist/models/Category.d.ts | 15 -- .../builds/default/dist/models/Category.js | 25 -- .../default/dist/models/Category.js.map | 1 - .../default/dist/models/ObjectSerializer.d.ts | 11 - .../default/dist/models/ObjectSerializer.js | 157 ------------ .../dist/models/ObjectSerializer.js.map | 1 - .../builds/default/dist/models/Order.d.ts | 26 -- .../builds/default/dist/models/Order.js | 54 ---- .../builds/default/dist/models/Order.js.map | 1 - .../builds/default/dist/models/Pet.d.ts | 28 --- .../builds/default/dist/models/Pet.js | 54 ---- .../builds/default/dist/models/Pet.js.map | 1 - .../builds/default/dist/models/Tag.d.ts | 15 -- .../builds/default/dist/models/Tag.js | 25 -- .../builds/default/dist/models/Tag.js.map | 1 - .../builds/default/dist/models/User.d.ts | 21 -- .../builds/default/dist/models/User.js | 55 ---- .../builds/default/dist/models/User.js.map | 1 - .../builds/default/dist/servers.d.ts | 7 - .../typescript/builds/default/dist/servers.js | 17 -- .../builds/default/dist/servers.js.map | 1 - .../builds/default/http/isomorphic-fetch.ts | 3 +- .../typescript/builds/default/models/all.ts | 6 + .../typescript/builds/default/test.ts | 12 + 65 files changed, 289 insertions(+), 1621 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/models_all.mustache create mode 100644 samples/client/petstore/typescript/builds/default/api.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/configuration.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/http.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/index.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/index.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/index.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/middleware.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Category.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Order.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/models/User.js.map delete mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.d.ts delete mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.js delete mode 100644 samples/client/petstore/typescript/builds/default/dist/servers.js.map create mode 100644 samples/client/petstore/typescript/builds/default/models/all.ts create mode 100644 samples/client/petstore/typescript/builds/default/test.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 44fe38314c21..12687fb5ba87 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -131,6 +131,9 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("servers.mustache", "servers.ts")); supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); + supportingFiles.add(new SupportingFile("models_all.mustache", "models", "all.ts")); + // TODO: add supporting files depending on cli parameter e.g. fetch vs angular + supportingFiles.add(new SupportingFile("generators/fetch/fetch.mustache", "api.ts")); // models // TODO: properly set model and api packages this.setModelPackage(""); diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache index 96d5b6951194..9fe4b31ba5e0 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache @@ -1,16 +1,41 @@ -# TODO: - -# Generic for HTTP Library: - - # Generate one class for each api - # constructor: Configuration + RequestFactory + ResponseProcessor - # one method for each API - # call request factory - # execute request with http library or w/e other library - # call response processor - # return promise - - # Why is this good? Because it allows each generator to return whatever they want to return, but they rely on the same - # internal process to get the response (if done correctly...) - -# Export correctly configured apis! \ No newline at end of file +import { ResponseContext } from './http/http'; +import * as models from './models/all'; +import { Configuration} from './configuration' + +{{#models}} +{{#model}} +import { {{name}} } from './models/{{name}}'; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} + +{{#operations}} +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "./apis/{{classname}}"; +export class {{classname}} { + private requestFactory: {{classname}}RequestFactory; + private responseProcessor: {{classname}}ResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new {{classname}}RequestFactory(configuration); + this.responseProcessor = new {{classname}}ResponseProcessor(); + } + +{{#operation}} + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.{{nickname}}(response); + }); + } + +{{/operation}} + +} + +{{/operations}} + + +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index dd200043238c..d0c749992b4d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -6,6 +6,7 @@ import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Promise { + console.log("Request: ", request); let method = request.getHttpMethod().toString(); let body = request.getBody(); @@ -21,7 +22,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { headers[key] = (headers[key] as Array).join("; "); } - return resp.text().then((body) => { + return resp.json().then((body) => { return new ResponseContext(resp.status, headers, body) }); }); diff --git a/modules/openapi-generator/src/main/resources/typescript/models_all.mustache b/modules/openapi-generator/src/main/resources/typescript/models_all.mustache new file mode 100644 index 000000000000..821581f4b37f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/models_all.mustache @@ -0,0 +1,5 @@ +{{#models}} +{{#model}} +export * from './{{name}}' +{{/model}} +{{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/api.ts b/samples/client/petstore/typescript/builds/default/api.ts new file mode 100644 index 000000000000..f3006877b921 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/api.ts @@ -0,0 +1,218 @@ +import { ResponseContext } from './http/http'; +import * as models from './models/all'; +import { Configuration} from './configuration' + +import { ApiResponse } from './models/ApiResponse'; +import { Category } from './models/Category'; +import { Order } from './models/Order'; +import { Pet } from './models/Pet'; +import { Tag } from './models/Tag'; +import { User } from './models/User'; + +import { PetApiRequestFactory, PetApiResponseProcessor} from "./apis/PetApi"; +export class PetApi { + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new PetApiRequestFactory(configuration); + this.responseProcessor = new PetApiResponseProcessor(); + } + + public addPet(pet: Pet, options?: any): Promise { + const requestContext = this.requestFactory.addPet(pet, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.addPet(response); + }); + } + + public deletePet(petId: number, apiKey?: string, options?: any): Promise { + const requestContext = this.requestFactory.deletePet(petId, apiKey, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.deletePet(response); + }); + } + + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise> { + const requestContext = this.requestFactory.findPetsByStatus(status, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.findPetsByStatus(response); + }); + } + + public findPetsByTags(tags: Array, options?: any): Promise> { + const requestContext = this.requestFactory.findPetsByTags(tags, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.findPetsByTags(response); + }); + } + + public getPetById(petId: number, options?: any): Promise { + const requestContext = this.requestFactory.getPetById(petId, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.getPetById(response); + }); + } + + public updatePet(pet: Pet, options?: any): Promise { + const requestContext = this.requestFactory.updatePet(pet, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.updatePet(response); + }); + } + + public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise { + const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.updatePetWithForm(response); + }); + } + + public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise { + const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.uploadFile(response); + }); + } + + +} + + + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "./apis/StoreApi"; +export class StoreApi { + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new StoreApiRequestFactory(configuration); + this.responseProcessor = new StoreApiResponseProcessor(); + } + + public deleteOrder(orderId: string, options?: any): Promise { + const requestContext = this.requestFactory.deleteOrder(orderId, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.deleteOrder(response); + }); + } + + public getInventory(options?: any): Promise<{ [key: string]: number; }> { + const requestContext = this.requestFactory.getInventory(options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.getInventory(response); + }); + } + + public getOrderById(orderId: number, options?: any): Promise { + const requestContext = this.requestFactory.getOrderById(orderId, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.getOrderById(response); + }); + } + + public placeOrder(order: Order, options?: any): Promise { + const requestContext = this.requestFactory.placeOrder(order, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.placeOrder(response); + }); + } + + +} + + + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "./apis/UserApi"; +export class UserApi { + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new UserApiRequestFactory(configuration); + this.responseProcessor = new UserApiResponseProcessor(); + } + + public createUser(user: User, options?: any): Promise { + const requestContext = this.requestFactory.createUser(user, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.createUser(response); + }); + } + + public createUsersWithArrayInput(user: Array, options?: any): Promise { + const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.createUsersWithArrayInput(response); + }); + } + + public createUsersWithListInput(user: Array, options?: any): Promise { + const requestContext = this.requestFactory.createUsersWithListInput(user, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.createUsersWithListInput(response); + }); + } + + public deleteUser(username: string, options?: any): Promise { + const requestContext = this.requestFactory.deleteUser(username, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.deleteUser(response); + }); + } + + public getUserByName(username: string, options?: any): Promise { + const requestContext = this.requestFactory.getUserByName(username, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.getUserByName(response); + }); + } + + public loginUser(username: string, password: string, options?: any): Promise { + const requestContext = this.requestFactory.loginUser(username, password, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.loginUser(response); + }); + } + + public logoutUser(options?: any): Promise { + const requestContext = this.requestFactory.logoutUser(options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.logoutUser(response); + }); + } + + public updateUser(username: string, user: User, options?: any): Promise { + const requestContext = this.requestFactory.updateUser(username, user, options); + + return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { + return this.responseProcessor.updateUser(response); + }); + } + + +} + + + diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts deleted file mode 100644 index 7dee88203bf8..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { BaseAPIRequestFactory } from './baseapi'; -import { RequestContext, ResponseContext } from '../http/http'; -import { ApiResponse } from '../models/ApiResponse'; -import { Pet } from '../models/Pet'; -export declare class PetApiRequestFactory extends BaseAPIRequestFactory { - addPet(pet: Pet, options?: any): RequestContext; - deletePet(petId: number, apiKey?: string, options?: any): RequestContext; - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext; - findPetsByTags(tags: Array, options?: any): RequestContext; - getPetById(petId: number, options?: any): RequestContext; - updatePet(pet: Pet, options?: any): RequestContext; - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext; - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext; -} -export declare class PetApiResponseProcessor { - addPet(response: ResponseContext): void; - deletePet(response: ResponseContext): void; - findPetsByStatus(response: ResponseContext): Array; - findPetsByTags(response: ResponseContext): Array; - getPetById(response: ResponseContext): Pet; - updatePet(response: ResponseContext): void; - updatePetWithForm(response: ResponseContext): void; - uploadFile(response: ResponseContext): ApiResponse; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js deleted file mode 100644 index 025572b4435b..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js +++ /dev/null @@ -1,237 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var baseapi_1 = require("./baseapi"); -var http_1 = require("../http/http"); -var FormData = require("form-data"); -var ObjectSerializer_1 = require("../models/ObjectSerializer"); -var PetApiRequestFactory = (function (_super) { - __extends(PetApiRequestFactory, _super); - function PetApiRequestFactory() { - return _super !== null && _super.apply(this, arguments) || this; - } - PetApiRequestFactory.prototype.addPet = function (pet, options) { - if (pet === null || pet === undefined) { - throw new baseapi_1.RequiredError('Required parameter pet was null or undefined when calling addPet.'); - } - var localVarPath = '/pet'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); - requestContext.setBody(serializedBody); - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.deletePet = function (petId, apiKey, options) { - if (petId === null || petId === undefined) { - throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling deletePet.'); - } - var localVarPath = '/pet/{petId}' - .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); - requestContext.setHeaderParam("", ObjectSerializer_1.ObjectSerializer.serialize(apiKey, "string")); - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.findPetsByStatus = function (status, options) { - if (status === null || status === undefined) { - throw new baseapi_1.RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); - } - var localVarPath = '/pet/findByStatus'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - if (status !== undefined) { - requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); - } - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.findPetsByTags = function (tags, options) { - if (tags === null || tags === undefined) { - throw new baseapi_1.RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); - } - var localVarPath = '/pet/findByTags'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - if (tags !== undefined) { - requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(tags, "Array")); - } - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.getPetById = function (petId, options) { - if (petId === null || petId === undefined) { - throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling getPetById.'); - } - var localVarPath = '/pet/{petId}' - .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - var authMethod = null; - authMethod = this.configuration.authMethods["api_key"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.updatePet = function (pet, options) { - if (pet === null || pet === undefined) { - throw new baseapi_1.RequiredError('Required parameter pet was null or undefined when calling updatePet.'); - } - var localVarPath = '/pet'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PUT); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); - requestContext.setBody(serializedBody); - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.updatePetWithForm = function (petId, name, status, options) { - if (petId === null || petId === undefined) { - throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - var localVarPath = '/pet/{petId}' - .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - var localVarFormParams = new FormData(); - if (name !== undefined) { - localVarFormParams.append('name', name); - } - if (status !== undefined) { - localVarFormParams.append('status', status); - } - requestContext.setBody(localVarFormParams); - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - PetApiRequestFactory.prototype.uploadFile = function (petId, additionalMetadata, file, options) { - if (petId === null || petId === undefined) { - throw new baseapi_1.RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); - } - var localVarPath = '/pet/{petId}/uploadImage' - .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - var localVarFormParams = new FormData(); - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata); - } - if (file !== undefined) { - localVarFormParams.append('file', file); - } - requestContext.setBody(localVarFormParams); - var authMethod = null; - authMethod = this.configuration.authMethods["petstore_auth"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - return PetApiRequestFactory; -}(baseapi_1.BaseAPIRequestFactory)); -exports.PetApiRequestFactory = PetApiRequestFactory; -var PetApiResponseProcessor = (function () { - function PetApiResponseProcessor() { - } - PetApiResponseProcessor.prototype.addPet = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - PetApiResponseProcessor.prototype.deletePet = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - PetApiResponseProcessor.prototype.findPetsByStatus = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Array"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - PetApiResponseProcessor.prototype.findPetsByTags = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Array"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - PetApiResponseProcessor.prototype.getPetById = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Pet"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - PetApiResponseProcessor.prototype.updatePet = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - PetApiResponseProcessor.prototype.updatePetWithForm = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - PetApiResponseProcessor.prototype.uploadFile = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "ApiResponse"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - return PetApiResponseProcessor; -}()); -exports.PetApiResponseProcessor = PetApiResponseProcessor; -//# sourceMappingURL=PetApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map deleted file mode 100644 index 68cc5a3fc75f..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/PetApi.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"PetApi.js","sourceRoot":"","sources":["../../apis/PetApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAC1E,oCAAsC;AACtC,+DAA4D;AAI5D;IAA0C,wCAAqB;IAA/D;;IA8SA,CAAC;IA3SU,qCAAM,GAAb,UAAc,GAAQ,EAAE,OAAa;QAEjC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,uBAAa,CAAC,mEAAmE,CAAC,CAAC;SAChG;QAIJ,IAAM,YAAY,GAAG,MAAM,CAAC;QAG5B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAWpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAElE,IAAM,kBAAkB,GAAG,CAAM,KAAK,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC3H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/F,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE7C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wCAAS,GAAhB,UAAiB,KAAa,EAAE,MAAe,EAAE,OAAa;QAE1D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAK5G,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAOhF,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,+CAAgB,GAAvB,UAAwB,MAA+C,EAAE,OAAa;QAElF,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE;YACzC,MAAM,IAAI,uBAAa,CAAC,gFAAgF,CAAC,CAAC;SAC7G;QAIJ,IAAM,YAAY,GAAG,mBAAmB,CAAC;QAGzC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,CAAC;SAChH;QASP,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAc,GAArB,UAAsB,IAAmB,EAAE,OAAa;QAEpD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,iBAAiB,CAAC;QAGvC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;SACpF;QASP,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAU,GAAjB,UAAkB,KAAa,EAAE,OAAa;QAE1C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWzG,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wCAAS,GAAhB,UAAiB,GAAQ,EAAE,OAAa;QAEpC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,uBAAa,CAAC,sEAAsE,CAAC,CAAC;SACnG;QAIJ,IAAM,YAAY,GAAG,MAAM,CAAC;QAG5B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWnG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAElE,IAAM,kBAAkB,GAAG,CAAM,KAAK,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC3H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/F,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE7C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,gDAAiB,GAAxB,UAAyB,KAAa,EAAE,IAAa,EAAE,MAAe,EAAE,OAAa;QAEjF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,gFAAgF,CAAC,CAAC;SAC7G;QAIJ,IAAM,YAAY,GAAG,cAAc;aAC3B,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAO1G,IAAI,kBAAkB,GAAG,IAAI,QAAQ,EAAE,CAAC;QAElC,IAAI,IAAI,KAAK,SAAS,EAAE;YAEpB,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAW,CAAC,CAAC;SAClD;QACD,IAAI,MAAM,KAAK,SAAS,EAAE;YAEtB,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAa,CAAC,CAAC;SACtD;QACP,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAI3C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAU,GAAjB,UAAkB,KAAa,EAAE,kBAA2B,EAAE,IAAU,EAAE,OAAa;QAEnF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,0BAA0B;aACvC,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGxE,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAO1G,IAAI,kBAAkB,GAAG,IAAI,QAAQ,EAAE,CAAC;QAElC,IAAI,kBAAkB,KAAK,SAAS,EAAE;YAElC,kBAAkB,CAAC,MAAM,CAAC,oBAAoB,EAAE,kBAAyB,CAAC,CAAC;SAC9E;QACD,IAAI,IAAI,KAAK,SAAS,EAAE;YAEpB,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAW,CAAC,CAAC;SAClD;QACP,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAI3C,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC5D,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,2BAAC;AAAD,CAAC,AA9SD,CAA0C,+BAAqB,GA8S9D;AA9SY,oDAAoB;AAoTjC;IAAA;IA8GA,CAAC;IAxGU,wCAAM,GAAb,UAAc,QAAyB;QACtC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,2CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,kDAAgB,GAAvB,UAAwB,QAAyB;QAChD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAe,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAe,CAAC;QACjG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,gDAAc,GAArB,UAAsB,QAAyB;QAC9C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAe,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAe,CAAC;QACjG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,4CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAQ,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAQ,CAAC;QAC5E,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,2CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,mDAAiB,GAAxB,UAAyB,QAAyB;QACjD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,4CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAgB,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAgB,CAAC;QACpG,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAEL,8BAAC;AAAD,CAAC,AA9GD,IA8GC;AA9GY,0DAAuB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts deleted file mode 100644 index 9d13d1b8e21f..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { BaseAPIRequestFactory } from './baseapi'; -import { RequestContext, ResponseContext } from '../http/http'; -import { Order } from '../models/Order'; -export declare class StoreApiRequestFactory extends BaseAPIRequestFactory { - deleteOrder(orderId: string, options?: any): RequestContext; - getInventory(options?: any): RequestContext; - getOrderById(orderId: number, options?: any): RequestContext; - placeOrder(order: Order, options?: any): RequestContext; -} -export declare class StoreApiResponseProcessor { - deleteOrder(response: ResponseContext): void; - getInventory(response: ResponseContext): { - [key: string]: number; - }; - getOrderById(response: ResponseContext): Order; - placeOrder(response: ResponseContext): Order; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js deleted file mode 100644 index 492d1205d61e..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js +++ /dev/null @@ -1,109 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var baseapi_1 = require("./baseapi"); -var http_1 = require("../http/http"); -var ObjectSerializer_1 = require("../models/ObjectSerializer"); -var StoreApiRequestFactory = (function (_super) { - __extends(StoreApiRequestFactory, _super); - function StoreApiRequestFactory() { - return _super !== null && _super.apply(this, arguments) || this; - } - StoreApiRequestFactory.prototype.deleteOrder = function (orderId, options) { - if (orderId === null || orderId === undefined) { - throw new baseapi_1.RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); - } - var localVarPath = '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); - return requestContext; - }; - StoreApiRequestFactory.prototype.getInventory = function (options) { - var localVarPath = '/store/inventory'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - var authMethod = null; - authMethod = this.configuration.authMethods["api_key"]; - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - return requestContext; - }; - StoreApiRequestFactory.prototype.getOrderById = function (orderId, options) { - if (orderId === null || orderId === undefined) { - throw new baseapi_1.RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); - } - var localVarPath = '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - return requestContext; - }; - StoreApiRequestFactory.prototype.placeOrder = function (order, options) { - if (order === null || order === undefined) { - throw new baseapi_1.RequiredError('Required parameter order was null or undefined when calling placeOrder.'); - } - var localVarPath = '/store/order'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(order || {}) : (order.toString() || ""); - requestContext.setBody(serializedBody); - return requestContext; - }; - return StoreApiRequestFactory; -}(baseapi_1.BaseAPIRequestFactory)); -exports.StoreApiRequestFactory = StoreApiRequestFactory; -var StoreApiResponseProcessor = (function () { - function StoreApiResponseProcessor() { - } - StoreApiResponseProcessor.prototype.deleteOrder = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - StoreApiResponseProcessor.prototype.getInventory = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "{ [key: string]: number; }"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - StoreApiResponseProcessor.prototype.getOrderById = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Order"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - StoreApiResponseProcessor.prototype.placeOrder = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "Order"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - return StoreApiResponseProcessor; -}()); -exports.StoreApiResponseProcessor = StoreApiResponseProcessor; -//# sourceMappingURL=StoreApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map deleted file mode 100644 index fa6a50a5a57a..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/StoreApi.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"StoreApi.js","sourceRoot":"","sources":["../../apis/StoreApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAE1E,+DAA4D;AAG5D;IAA4C,0CAAqB;IAAjE;;IAuHA,CAAC;IApHU,4CAAW,GAAlB,UAAmB,OAAe,EAAE,OAAa;QAE7C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,wBAAwB;aACrC,OAAO,CAAC,GAAG,GAAG,SAAS,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAG5E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAazG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAY,GAAnB,UAAoB,OAAa;QAGhC,IAAM,YAAY,GAAG,kBAAkB,CAAC;QAGxC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAWzG,IAAI,UAAU,GAAG,IAAI,CAAC;QAEnB,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAY,GAAnB,UAAoB,OAAe,EAAE,OAAa;QAE9C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,uBAAa,CAAC,6EAA6E,CAAC,CAAC;SAC1G;QAIJ,IAAM,YAAY,GAAG,wBAAwB;aACrC,OAAO,CAAC,GAAG,GAAG,SAAS,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAG5E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,2CAAU,GAAjB,UAAkB,KAAY,EAAE,OAAa;QAEzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,uBAAa,CAAC,yEAAyE,CAAC,CAAC;SACtG;QAIJ,IAAM,YAAY,GAAG,cAAc,CAAC;QAGpC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,OAAO,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC7H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACnG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,6BAAC;AAAD,CAAC,AAvHD,CAA4C,+BAAqB,GAuHhE;AAvHY,wDAAsB;AA6HnC;IAAA;IA2DA,CAAC;IArDU,+CAAW,GAAlB,UAAmB,QAAyB;QAC3C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,gDAAY,GAAnB,UAAoB,QAAyB;QAC5C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAA+B,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAA+B,CAAC;QACjJ,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,gDAAY,GAAnB,UAAoB,QAAyB;QAC5C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAU,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAU,CAAC;QAClF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,8CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAU,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAU,CAAC;QAClF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAEL,gCAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,8DAAyB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts deleted file mode 100644 index e8f92cc42357..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { BaseAPIRequestFactory } from './baseapi'; -import { RequestContext, ResponseContext } from '../http/http'; -import { User } from '../models/User'; -export declare class UserApiRequestFactory extends BaseAPIRequestFactory { - createUser(user: User, options?: any): RequestContext; - createUsersWithArrayInput(user: Array, options?: any): RequestContext; - createUsersWithListInput(user: Array, options?: any): RequestContext; - deleteUser(username: string, options?: any): RequestContext; - getUserByName(username: string, options?: any): RequestContext; - loginUser(username: string, password: string, options?: any): RequestContext; - logoutUser(options?: any): RequestContext; - updateUser(username: string, user: User, options?: any): RequestContext; -} -export declare class UserApiResponseProcessor { - createUser(response: ResponseContext): void; - createUsersWithArrayInput(response: ResponseContext): void; - createUsersWithListInput(response: ResponseContext): void; - deleteUser(response: ResponseContext): void; - getUserByName(response: ResponseContext): User; - loginUser(response: ResponseContext): string; - logoutUser(response: ResponseContext): void; - updateUser(response: ResponseContext): void; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js deleted file mode 100644 index 558ffdad15f3..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js +++ /dev/null @@ -1,181 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var baseapi_1 = require("./baseapi"); -var http_1 = require("../http/http"); -var ObjectSerializer_1 = require("../models/ObjectSerializer"); -var UserApiRequestFactory = (function (_super) { - __extends(UserApiRequestFactory, _super); - function UserApiRequestFactory() { - return _super !== null && _super.apply(this, arguments) || this; - } - UserApiRequestFactory.prototype.createUser = function (user, options) { - if (user === null || user === undefined) { - throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUser.'); - } - var localVarPath = '/user'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); - requestContext.setBody(serializedBody); - return requestContext; - }; - UserApiRequestFactory.prototype.createUsersWithArrayInput = function (user, options) { - if (user === null || user === undefined) { - throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - var localVarPath = '/user/createWithArray'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); - requestContext.setBody(serializedBody); - return requestContext; - }; - UserApiRequestFactory.prototype.createUsersWithListInput = function (user, options) { - if (user === null || user === undefined) { - throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - var localVarPath = '/user/createWithList'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); - requestContext.setBody(serializedBody); - return requestContext; - }; - UserApiRequestFactory.prototype.deleteUser = function (username, options) { - if (username === null || username === undefined) { - throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling deleteUser.'); - } - var localVarPath = '/user/{username}' - .replace('{' + 'username' + '}', encodeURIComponent(String(username))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); - return requestContext; - }; - UserApiRequestFactory.prototype.getUserByName = function (username, options) { - if (username === null || username === undefined) { - throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling getUserByName.'); - } - var localVarPath = '/user/{username}' - .replace('{' + 'username' + '}', encodeURIComponent(String(username))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - return requestContext; - }; - UserApiRequestFactory.prototype.loginUser = function (username, password, options) { - if (username === null || username === undefined) { - throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling loginUser.'); - } - if (password === null || password === undefined) { - throw new baseapi_1.RequiredError('Required parameter password was null or undefined when calling loginUser.'); - } - var localVarPath = '/user/login'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - if (username !== undefined) { - requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(username, "string")); - } - if (password !== undefined) { - requestContext.setQueryParam("", ObjectSerializer_1.ObjectSerializer.serialize(password, "string")); - } - return requestContext; - }; - UserApiRequestFactory.prototype.logoutUser = function (options) { - var localVarPath = '/user/logout'; - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); - return requestContext; - }; - UserApiRequestFactory.prototype.updateUser = function (username, user, options) { - if (username === null || username === undefined) { - throw new baseapi_1.RequiredError('Required parameter username was null or undefined when calling updateUser.'); - } - if (user === null || user === undefined) { - throw new baseapi_1.RequiredError('Required parameter user was null or undefined when calling updateUser.'); - } - var localVarPath = '/user/{username}' - .replace('{' + 'username' + '}', encodeURIComponent(String(username))); - var requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PUT); - requestContext.setHeaderParam("Content-Type", "application/json"); - var needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - var serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); - requestContext.setBody(serializedBody); - return requestContext; - }; - return UserApiRequestFactory; -}(baseapi_1.BaseAPIRequestFactory)); -exports.UserApiRequestFactory = UserApiRequestFactory; -var UserApiResponseProcessor = (function () { - function UserApiResponseProcessor() { - } - UserApiResponseProcessor.prototype.createUser = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - UserApiResponseProcessor.prototype.createUsersWithArrayInput = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - UserApiResponseProcessor.prototype.createUsersWithListInput = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - UserApiResponseProcessor.prototype.deleteUser = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - UserApiResponseProcessor.prototype.getUserByName = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "User"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - UserApiResponseProcessor.prototype.loginUser = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - var body = ObjectSerializer_1.ObjectSerializer.deserialize(response.body, "string"); - if (responseOK) { - return body; - } - else { - throw body; - } - }; - UserApiResponseProcessor.prototype.logoutUser = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - UserApiResponseProcessor.prototype.updateUser = function (response) { - var responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); - } - }; - return UserApiResponseProcessor; -}()); -exports.UserApiResponseProcessor = UserApiResponseProcessor; -//# sourceMappingURL=UserApi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map deleted file mode 100644 index de37ea2320f5..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/UserApi.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"UserApi.js","sourceRoot":"","sources":["../../apis/UserApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qCAAiE;AACjE,qCAA0E;AAE1E,+DAA4D;AAG5D;IAA2C,yCAAqB;IAAhE;;IAiQA,CAAC;IA9PU,0CAAU,GAAjB,UAAkB,IAAU,EAAE,OAAa;QAEvC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,OAAO,CAAC;QAG7B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,MAAM,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC5H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yDAAyB,GAAhC,UAAiC,IAAiB,EAAE,OAAa;QAE7D,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,uFAAuF,CAAC,CAAC;SACpH;QAIJ,IAAM,YAAY,GAAG,uBAAuB,CAAC;QAG7C,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,mBAAmB,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QACzI,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,wDAAwB,GAA/B,UAAgC,IAAiB,EAAE,OAAa;QAE5D,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,sFAAsF,CAAC,CAAC;SACnH;QAIJ,IAAM,YAAY,GAAG,sBAAsB,CAAC;QAG5C,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,IAAI,CAAC,CAAC;QAUpG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,mBAAmB,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QACzI,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,QAAgB,EAAE,OAAa;QAE7C,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,MAAM,CAAC,CAAC;QAazG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,6CAAa,GAApB,UAAqB,QAAgB,EAAE,OAAa;QAEhD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,+EAA+E,CAAC,CAAC;SAC5G;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,yCAAS,GAAhB,UAAiB,QAAgB,EAAE,QAAgB,EAAE,OAAa;QAE9D,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,2EAA2E,CAAC,CAAC;SACxG;QAGD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,2EAA2E,CAAC,CAAC;SACxG;QAIJ,IAAM,YAAY,GAAG,aAAa,CAAC;QAGnC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAGnG,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjF;QACD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,mCAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjF;QAWJ,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,OAAa;QAG9B,IAAM,YAAY,GAAG,cAAc,CAAC;QAGpC,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAatG,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,0CAAU,GAAjB,UAAkB,QAAgB,EAAE,IAAU,EAAE,OAAa;QAEzD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC7C,MAAM,IAAI,uBAAa,CAAC,4EAA4E,CAAC,CAAC;SACzG;QAGD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,uBAAa,CAAC,wEAAwE,CAAC,CAAC;SACrG;QAIJ,IAAM,YAAY,GAAG,kBAAkB;aAC/B,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAG9E,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,iBAAU,CAAC,GAAG,CAAC,CAAC;QAUnG,cAAc,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAGlE,IAAM,kBAAkB,GAAG,CAAM,MAAM,KAAK,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC;QAC5H,IAAM,cAAc,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAI1C,OAAO,cAAc,CAAC;IACvB,CAAC;IAEL,4BAAC;AAAD,CAAC,AAjQD,CAA2C,+BAAqB,GAiQ/D;AAjQY,sDAAqB;AAuQlC;IAAA;IAwGA,CAAC;IAlGU,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,4DAAyB,GAAhC,UAAiC,QAAyB;QACzD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,2DAAwB,GAA/B,UAAgC,QAAyB;QACxD,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,gDAAa,GAApB,UAAqB,QAAyB;QAC7C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAS,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAS,CAAC;QAC/E,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,4CAAS,GAAhB,UAAiB,QAAyB;QACzC,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAC5G,IAAM,IAAI,GAAW,mCAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAW,CAAC;QACrF,IAAI,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACN;aAAM;YAEN,MAAM,IAAI,CAAA;SACV;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAMM,6CAAU,GAAjB,UAAkB,QAAyB;QAC1C,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,IAAI,GAAG,CAAC;QAE5G,IAAI,CAAC,UAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;SACzE;IACL,CAAC;IAEL,+BAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4DAAwB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts deleted file mode 100644 index f819e9175de0..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Configuration } from '../configuration'; -export declare const COLLECTION_FORMATS: { - csv: string; - ssv: string; - tsv: string; - pipes: string; -}; -export declare class BaseAPIRequestFactory { - protected configuration: Configuration; - constructor(configuration: Configuration); -} -export declare class RequiredError extends Error { - field: string; - name: "RequiredError"; - constructor(field: string, msg?: string); -} diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js deleted file mode 100644 index 88edf23e013a..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; -var BaseAPIRequestFactory = (function () { - function BaseAPIRequestFactory(configuration) { - this.configuration = configuration; - } - return BaseAPIRequestFactory; -}()); -exports.BaseAPIRequestFactory = BaseAPIRequestFactory; -; -var RequiredError = (function (_super) { - __extends(RequiredError, _super); - function RequiredError(field, msg) { - var _this = _super.call(this, msg) || this; - _this.field = field; - _this.name = "RequiredError"; - return _this; - } - return RequiredError; -}(Error)); -exports.RequiredError = RequiredError; -//# sourceMappingURL=baseapi.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map b/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map deleted file mode 100644 index 384b2bd789e4..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/apis/baseapi.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"baseapi.js","sourceRoot":"","sources":["../../apis/baseapi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMa,QAAA,kBAAkB,GAAG;IAC9B,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,GAAG;CACb,CAAC;AAQF;IAEI,+BAAsB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAClD,CAAC;IACL,4BAAC;AAAD,CAAC,AAJD,IAIC;AAJY,sDAAqB;AAIjC,CAAC;AAQF;IAAmC,iCAAK;IAEpC,uBAAmB,KAAa,EAAE,GAAY;QAA9C,YACI,kBAAM,GAAG,CAAC,SACb;QAFkB,WAAK,GAAL,KAAK,CAAQ;QADhC,UAAI,GAAoB,eAAe,CAAC;;IAGxC,CAAC;IACL,oBAAC;AAAD,CAAC,AALD,CAAmC,KAAK,GAKvC;AALY,sCAAa"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts b/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts deleted file mode 100644 index 0edccf0e3949..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/auth/auth.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { RequestContext } from '../http/http'; -export declare abstract class SecurityAuthentication { - private name; - constructor(name: string); - getName(): string; - abstract applySecurityAuthentication(context: RequestContext): void; -} -export declare class NoAuthentication extends SecurityAuthentication { - constructor(); - applySecurityAuthentication(_context: RequestContext): void; -} -export declare class APIKeyAuthentication extends SecurityAuthentication { - private paramName; - private keyLocation; - private apiKey; - constructor(authName: string, paramName: string, keyLocation: "query" | "header" | "cookie", apiKey: string); - applySecurityAuthentication(context: RequestContext): void; -} -export declare class HttpBasicAuthentication extends SecurityAuthentication { - private username; - private password; - constructor(authName: string, username: string, password: string); - applySecurityAuthentication(context: RequestContext): void; -} -export declare class OAuth2Authentication extends SecurityAuthentication { - constructor(authName: string); - applySecurityAuthentication(context: RequestContext): void; -} -export declare type AuthMethods = { - "api_key"?: APIKeyAuthentication; - "petstore_auth"?: OAuth2Authentication; -}; -export declare type ApiKeyConfiguration = string; -export declare type HttpBasicConfiguration = { - "username": string; - "password": string; -}; -export declare type OAuth2Configuration = string; -export declare type AuthMethodsConfiguration = { - "api_key"?: ApiKeyConfiguration; - "petstore_auth"?: OAuth2Configuration; -}; -export declare function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods; diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js deleted file mode 100644 index 20869b9d94ff..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var btoa = require("btoa"); -var SecurityAuthentication = (function () { - function SecurityAuthentication(name) { - this.name = name; - } - SecurityAuthentication.prototype.getName = function () { - return this.name; - }; - return SecurityAuthentication; -}()); -exports.SecurityAuthentication = SecurityAuthentication; -var NoAuthentication = (function (_super) { - __extends(NoAuthentication, _super); - function NoAuthentication() { - return _super.call(this, "_no_auth") || this; - } - NoAuthentication.prototype.applySecurityAuthentication = function (_context) { - }; - return NoAuthentication; -}(SecurityAuthentication)); -exports.NoAuthentication = NoAuthentication; -var APIKeyAuthentication = (function (_super) { - __extends(APIKeyAuthentication, _super); - function APIKeyAuthentication(authName, paramName, keyLocation, apiKey) { - var _this = _super.call(this, authName) || this; - _this.paramName = paramName; - _this.keyLocation = keyLocation; - _this.apiKey = apiKey; - return _this; - } - APIKeyAuthentication.prototype.applySecurityAuthentication = function (context) { - if (this.keyLocation === "header") { - context.setHeaderParam(this.paramName, this.apiKey); - } - else if (this.keyLocation === "cookie") { - context.addCookie(this.paramName, this.apiKey); - } - else if (this.keyLocation === "query") { - context.setQueryParam(this.paramName, this.apiKey); - } - }; - return APIKeyAuthentication; -}(SecurityAuthentication)); -exports.APIKeyAuthentication = APIKeyAuthentication; -var HttpBasicAuthentication = (function (_super) { - __extends(HttpBasicAuthentication, _super); - function HttpBasicAuthentication(authName, username, password) { - var _this = _super.call(this, authName) || this; - _this.username = username; - _this.password = password; - return _this; - } - HttpBasicAuthentication.prototype.applySecurityAuthentication = function (context) { - var comb = this.username + ":" + this.password; - context.setHeaderParam("Authentication", "Basic " + btoa(comb)); - }; - return HttpBasicAuthentication; -}(SecurityAuthentication)); -exports.HttpBasicAuthentication = HttpBasicAuthentication; -var OAuth2Authentication = (function (_super) { - __extends(OAuth2Authentication, _super); - function OAuth2Authentication(authName) { - return _super.call(this, authName) || this; - } - OAuth2Authentication.prototype.applySecurityAuthentication = function (context) { - }; - return OAuth2Authentication; -}(SecurityAuthentication)); -exports.OAuth2Authentication = OAuth2Authentication; -function configureAuthMethods(conf) { - var authMethods = {}; - if (!conf) { - return authMethods; - } - if (conf["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); - } - if (conf["petstore_auth"]) { - authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); - } - return authMethods; -} -exports.configureAuthMethods = configureAuthMethods; -//# sourceMappingURL=auth.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map b/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map deleted file mode 100644 index 68239cd59086..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/auth/auth.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../auth/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,2BAA6B;AAE7B;IAEC,gCAA2B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAEvC,CAAC;IAMM,wCAAO,GAAd;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAIF,6BAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBqB,wDAAsB;AAkB5C;IAAsC,oCAAsB;IAE3D;eACC,kBAAM,UAAU,CAAC;IAClB,CAAC;IAEM,sDAA2B,GAAlC,UAAmC,QAAwB;IAE3D,CAAC;IACF,uBAAC;AAAD,CAAC,AATD,CAAsC,sBAAsB,GAS3D;AATY,4CAAgB;AAW7B;IAA0C,wCAAsB;IAE/D,8BAAmB,QAAgB,EAAU,SAAiB,EAAU,WAA0C,EAAU,MAAc;QAA1I,YACC,kBAAM,QAAQ,CAAC,SACf;QAF4C,eAAS,GAAT,SAAS,CAAQ;QAAU,iBAAW,GAAX,WAAW,CAA+B;QAAU,YAAM,GAAN,MAAM,CAAQ;;IAE1I,CAAC;IAEM,0DAA2B,GAAlC,UAAmC,OAAuB;QACzD,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;YAClC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpD;aAAM,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;YACzC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SAC/C;aAAM,IAAI,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE;YACxC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACnD;IACF,CAAC;IACF,2BAAC;AAAD,CAAC,AAfD,CAA0C,sBAAsB,GAe/D;AAfY,oDAAoB;AAkBjC;IAA6C,2CAAsB;IAElE,iCAAmB,QAAgB,EAAU,QAAgB,EAAU,QAAgB;QAAvF,YACC,kBAAM,QAAQ,CAAC,SACf;QAF4C,cAAQ,GAAR,QAAQ,CAAQ;QAAU,cAAQ,GAAR,QAAQ,CAAQ;;IAEvF,CAAC;IAEM,6DAA2B,GAAlC,UAAmC,OAAuB;QACzD,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/C,OAAO,CAAC,cAAc,CAAC,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IACF,8BAAC;AAAD,CAAC,AAVD,CAA6C,sBAAsB,GAUlE;AAVY,0DAAuB;AAYpC;IAA0C,wCAAsB;IAC/D,8BAAmB,QAAgB;eAClC,kBAAM,QAAQ,CAAC;IAChB,CAAC;IAEM,0DAA2B,GAAlC,UAAmC,OAAuB;IAE1D,CAAC;IACF,2BAAC;AAAD,CAAC,AARD,CAA0C,sBAAsB,GAQ/D;AARY,oDAAoB;AAqBjC,SAAgB,oBAAoB,CAAC,IAA0C;IAC9E,IAAI,WAAW,GAAgB,EAC9B,CAAA;IAED,IAAI,CAAC,IAAI,EAAE;QACV,OAAO,WAAW,CAAC;KACnB;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE;QACpB,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,oBAAoB,CAAC,SAAS,EAAG,SAAS,EAAE,QAAQ,EAAW,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;KAC7G;IAED,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE;QAC1B,WAAW,CAAC,eAAe,CAAC,GAAG,IAAI,oBAAoB,CAAC,eAAe,CAAC,CAAC;KACzE;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAjBD,oDAiBC"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts b/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts deleted file mode 100644 index 85f2ac938130..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/configuration.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { HttpLibrary } from './http/http'; -import { Middleware } from './middleware'; -import { ServerConfiguration } from './servers'; -import { AuthMethods, AuthMethodsConfiguration } from './auth/auth'; -export interface ConfigurationParameters { - baseServer?: ServerConfiguration; - httpApi?: HttpLibrary; - middleware?: Middleware[]; - authMethods?: AuthMethodsConfiguration; -} -export declare class Configuration { - baseServer: ServerConfiguration; - httpApi: HttpLibrary; - middleware: Middleware[]; - authMethods: AuthMethods; - constructor(conf?: ConfigurationParameters); -} diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.js b/samples/client/petstore/typescript/builds/default/dist/configuration.js deleted file mode 100644 index 404f626ac919..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/configuration.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var isomorphic_fetch_1 = require("./http/isomorphic-fetch"); -var servers_1 = require("./servers"); -var auth_1 = require("./auth/auth"); -var Configuration = (function () { - function Configuration(conf) { - if (conf === void 0) { conf = {}; } - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers_1.servers[0]; - this.httpApi = conf.httpApi || new isomorphic_fetch_1.IsomorphicFetchHttpLibrary(); - this.middleware = conf.middleware || []; - this.authMethods = auth_1.configureAuthMethods(conf.authMethods); - } - return Configuration; -}()); -exports.Configuration = Configuration; -//# sourceMappingURL=configuration.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/configuration.js.map b/samples/client/petstore/typescript/builds/default/dist/configuration.js.map deleted file mode 100644 index 346874cb8154..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/configuration.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../configuration.ts"],"names":[],"mappings":";;AAEA,4DAAmE;AACnE,qCAAuD;AACvD,oCAAwF;AAUxF;IAOI,uBAAY,IAAkC;QAAlC,qBAAA,EAAA,SAAkC;QAC1C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAO,CAAC,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,6CAA0B,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,2BAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IACL,oBAAC;AAAD,CAAC,AAbD,IAaC;AAbY,sCAAa"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts b/samples/client/petstore/typescript/builds/default/dist/fetch/api.d.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js deleted file mode 100644 index bb4728734413..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=api.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map b/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map deleted file mode 100644 index 05a42e6f2602..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/fetch/api.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"api.js","sourceRoot":"","sources":["../../fetch/api.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts b/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts deleted file mode 100644 index 00a823a23859..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/http.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as FormData from "form-data"; -export declare enum HttpMethod { - GET = "GET", - HEAD = "HEAD", - POST = "POST", - PUT = "PUT", - DELETE = "DELETE", - CONNECT = "CONNECT", - OPTIONS = "OPTIONS", - TRACE = "TRACE", - PATCH = "PATCH" -} -export interface FormEntry { - contentDisposition: string; - value: string | Blob; -} -export declare class HttpException extends Error { - constructor(msg: string); -} -export declare class RequestContext { - private httpMethod; - private headers; - private body; - private url; - constructor(url: string, httpMethod: HttpMethod); - getUrl(): string; - setUrl(url: string): void; - setBody(body: string | FormData): void; - getHttpMethod(): HttpMethod; - getHeaders(): { - [key: string]: string; - }; - getBody(): string | FormData; - setQueryParam(name: string, value: string): void; - addCookie(name: string, value: string): void; - setHeaderParam(key: string, value: string): void; -} -export declare class ResponseContext { - httpStatusCode: number; - headers: { - [key: string]: string; - }; - body: string; - constructor(httpStatusCode: number, headers: { - [key: string]: string; - }, body: string); -} -export interface HttpLibrary { - send(request: RequestContext): Promise; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.js b/samples/client/petstore/typescript/builds/default/dist/http/http.js deleted file mode 100644 index 9cf226eb4ba0..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/http.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - } - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var URLParse = require("url-parse"); -var HttpMethod; -(function (HttpMethod) { - HttpMethod["GET"] = "GET"; - HttpMethod["HEAD"] = "HEAD"; - HttpMethod["POST"] = "POST"; - HttpMethod["PUT"] = "PUT"; - HttpMethod["DELETE"] = "DELETE"; - HttpMethod["CONNECT"] = "CONNECT"; - HttpMethod["OPTIONS"] = "OPTIONS"; - HttpMethod["TRACE"] = "TRACE"; - HttpMethod["PATCH"] = "PATCH"; -})(HttpMethod = exports.HttpMethod || (exports.HttpMethod = {})); -var HttpException = (function (_super) { - __extends(HttpException, _super); - function HttpException(msg) { - return _super.call(this, msg) || this; - } - return HttpException; -}(Error)); -exports.HttpException = HttpException; -var RequestContext = (function () { - function RequestContext(url, httpMethod) { - this.httpMethod = httpMethod; - this.headers = {}; - this.body = ""; - this.url = URLParse(url, true); - } - RequestContext.prototype.getUrl = function () { - return this.url.toString(); - }; - RequestContext.prototype.setUrl = function (url) { - this.url = URLParse(url, true); - }; - RequestContext.prototype.setBody = function (body) { - if (this.httpMethod === HttpMethod.GET) { - throw new HttpException("Body should not be included in GET-Requests!"); - } - this.body = body; - }; - RequestContext.prototype.getHttpMethod = function () { - return this.httpMethod; - }; - RequestContext.prototype.getHeaders = function () { - return this.headers; - }; - RequestContext.prototype.getBody = function () { - return this.body; - }; - RequestContext.prototype.setQueryParam = function (name, value) { - var queryObj = this.url.query; - queryObj[name] = value; - this.url.set("query", queryObj); - }; - RequestContext.prototype.addCookie = function (name, value) { - if (!this.headers["Cookie"]) { - this.headers["Cookie"] = ""; - } - this.headers["Cookie"] += name + "=" + value + "; "; - }; - RequestContext.prototype.setHeaderParam = function (key, value) { - this.headers[key] = value; - }; - return RequestContext; -}()); -exports.RequestContext = RequestContext; -var ResponseContext = (function () { - function ResponseContext(httpStatusCode, headers, body) { - this.httpStatusCode = httpStatusCode; - this.headers = headers; - this.body = body; - } - return ResponseContext; -}()); -exports.ResponseContext = ResponseContext; -//# sourceMappingURL=http.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/http.js.map b/samples/client/petstore/typescript/builds/default/dist/http/http.js.map deleted file mode 100644 index 9d17a13734c8..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/http.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"http.js","sourceRoot":"","sources":["../../http/http.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,oCAAsC;AAEtC,IAAY,UAUX;AAVD,WAAY,UAAU;IAClB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IACf,6BAAe,CAAA;AACnB,CAAC,EAVW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAUrB;AAQD;IAAmC,iCAAK;IACpC,uBAAmB,GAAW;eAC1B,kBAAM,GAAG,CAAC;IACd,CAAC;IACL,oBAAC;AAAD,CAAC,AAJD,CAAmC,KAAK,GAIvC;AAJY,sCAAa;AAM1B;IAKI,wBAAmB,GAAW,EAAU,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAJtD,YAAO,GAA8B,EAAE,CAAC;QACxC,SAAI,GAAsB,EAAE,CAAC;QAIjC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAEM,+BAAM,GAAb;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAEM,+BAAM,GAAb,UAAc,GAAW;QACxB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAGM,gCAAO,GAAd,UAAe,IAAuB;QAElC,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,CAAC,GAAG,EAAE;YACpC,MAAM,IAAI,aAAa,CAAC,8CAA8C,CAAC,CAAC;SAC3E;QAKD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAErB,CAAC;IAEM,sCAAa,GAApB;QACC,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,mCAAU,GAAjB;QACC,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,gCAAO,GAAd;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEG,sCAAa,GAApB,UAAqB,IAAY,EAAE,KAAa;QACzC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAEM,kCAAS,GAAhB,UAAiB,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;IACxD,CAAC;IAEM,uCAAc,GAArB,UAAsB,GAAW,EAAE,KAAa;QAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IACL,qBAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,wCAAc;AA6D3B;IAEI,yBAA0B,cAAsB,EACrC,OAAkC,EAAS,IAAY;QADxC,mBAAc,GAAd,cAAc,CAAQ;QACrC,YAAO,GAAP,OAAO,CAA2B;QAAS,SAAI,GAAJ,IAAI,CAAQ;IAClE,CAAC;IAEL,sBAAC;AAAD,CAAC,AAND,IAMC;AANY,0CAAe"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts deleted file mode 100644 index f19b66c9ed3b..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { HttpLibrary, RequestContext, ResponseContext } from './http'; -import 'isomorphic-fetch'; -export declare class IsomorphicFetchHttpLibrary implements HttpLibrary { - send(request: RequestContext): Promise; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js deleted file mode 100644 index 26b39b311e9a..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var http_1 = require("./http"); -var e6p = require("es6-promise"); -e6p.polyfill(); -require("isomorphic-fetch"); -var IsomorphicFetchHttpLibrary = (function () { - function IsomorphicFetchHttpLibrary() { - } - IsomorphicFetchHttpLibrary.prototype.send = function (request) { - var method = request.getHttpMethod().toString(); - var body = request.getBody(); - return fetch(request.getUrl(), { - method: method, - body: body, - headers: request.getHeaders(), - credentials: "same-origin" - }).then(function (resp) { - var headers = resp.headers._headers; - for (var key in headers) { - headers[key] = headers[key].join("; "); - } - return resp.text().then(function (body) { - return new http_1.ResponseContext(resp.status, headers, body); - }); - }); - }; - return IsomorphicFetchHttpLibrary; -}()); -exports.IsomorphicFetchHttpLibrary = IsomorphicFetchHttpLibrary; -//# sourceMappingURL=isomorphic-fetch.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map b/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map deleted file mode 100644 index 4b5d3e858522..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/http/isomorphic-fetch.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"isomorphic-fetch.js","sourceRoot":"","sources":["../../http/isomorphic-fetch.ts"],"names":[],"mappings":";;AAAA,+BAAoE;AACpE,iCAAkC;AAClC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACf,4BAA0B;AAE1B;IAAA;IAwBA,CAAC;IAtBU,yCAAI,GAAX,UAAY,OAAuB;QAC/B,IAAI,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;YAC3B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAW;YACjB,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;YAC7B,WAAW,EAAE,aAAa;SAC7B,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YAET,IAAI,OAAO,GAAI,IAAI,CAAC,OAAe,CAAC,QAAQ,CAAC;YAC7C,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;gBACrB,OAAO,CAAC,GAAG,CAAC,GAAI,OAAO,CAAC,GAAG,CAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC7D;YAED,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAC,IAAI;gBACzB,OAAO,IAAI,sBAAe,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;YAC1D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IAEP,CAAC;IACL,iCAAC;AAAD,CAAC,AAxBD,IAwBC;AAxBY,gEAA0B"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/index.d.ts b/samples/client/petstore/typescript/builds/default/dist/index.d.ts deleted file mode 100644 index e9fa76f6079f..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './configuration'; -export * from './http/http'; -export * from './auth/auth'; -export * from './middleware'; -export * from './servers'; -export * from './http/isomorphic-fetch'; diff --git a/samples/client/petstore/typescript/builds/default/dist/index.js b/samples/client/petstore/typescript/builds/default/dist/index.js deleted file mode 100644 index e3bfaf4d3544..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -Object.defineProperty(exports, "__esModule", { value: true }); -__export(require("./configuration")); -__export(require("./http/http")); -__export(require("./auth/auth")); -__export(require("./servers")); -__export(require("./http/isomorphic-fetch")); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/index.js.map b/samples/client/petstore/typescript/builds/default/dist/index.js.map deleted file mode 100644 index 0ac7879e10dd..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+B;AAC/B,iCAA4B;AAC5B,iCAA4B;AAE5B,+BAA0B;AAI1B,6CAAwC"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts b/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts deleted file mode 100644 index f8c719e0b389..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/middleware.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { RequestContext, ResponseContext } from './http/http'; -export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.js b/samples/client/petstore/typescript/builds/default/dist/middleware.js deleted file mode 100644 index f83bf79d25c6..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/middleware.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=middleware.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/middleware.js.map b/samples/client/petstore/typescript/builds/default/dist/middleware.js.map deleted file mode 100644 index 71e436453e0b..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/middleware.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../middleware.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts deleted file mode 100644 index 8d0cd97507dc..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export declare class ApiResponse { - 'code'?: number; - 'type'?: string; - 'message'?: string; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js deleted file mode 100644 index 0ef210da7882..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ApiResponse = (function () { - function ApiResponse() { - } - ApiResponse.getAttributeTypeMap = function () { - return ApiResponse.attributeTypeMap; - }; - ApiResponse.discriminator = undefined; - ApiResponse.attributeTypeMap = [ - { - "name": "code", - "baseName": "code", - "type": "number" - }, - { - "name": "type", - "baseName": "type", - "type": "string" - }, - { - "name": "message", - "baseName": "message", - "type": "string" - } - ]; - return ApiResponse; -}()); -exports.ApiResponse = ApiResponse; -//# sourceMappingURL=ApiResponse.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map b/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map deleted file mode 100644 index 666330d7e2ce..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ApiResponse.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ApiResponse.js","sourceRoot":"","sources":["../../models/ApiResponse.ts"],"names":[],"mappings":";;AAOA;IAAA;IA2BA,CAAC;IAHU,+BAAmB,GAA1B;QACI,OAAO,WAAW,CAAC,gBAAgB,CAAC;IACxC,CAAC;IArBM,yBAAa,GAAuB,SAAS,CAAC;IAE9C,4BAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,SAAS;YACrB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,kBAAC;CAAA,AA3BD,IA2BC;AA3BY,kCAAW"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts deleted file mode 100644 index 727a8ab12aff..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Category.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare class Category { - 'id'?: number; - 'name'?: string; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.js b/samples/client/petstore/typescript/builds/default/dist/models/Category.js deleted file mode 100644 index 1afdb16f0144..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Category.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Category = (function () { - function Category() { - } - Category.getAttributeTypeMap = function () { - return Category.attributeTypeMap; - }; - Category.discriminator = undefined; - Category.attributeTypeMap = [ - { - "name": "id", - "baseName": "id", - "type": "number" - }, - { - "name": "name", - "baseName": "name", - "type": "string" - } - ]; - return Category; -}()); -exports.Category = Category; -//# sourceMappingURL=Category.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map deleted file mode 100644 index 8906be35442c..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Category.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../models/Category.ts"],"names":[],"mappings":";;AAOA;IAAA;IAqBA,CAAC;IAHU,4BAAmB,GAA1B;QACI,OAAO,QAAQ,CAAC,gBAAgB,CAAC;IACrC,CAAC;IAhBM,sBAAa,GAAuB,SAAS,CAAC;IAE9C,yBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,eAAC;CAAA,AArBD,IAqBC;AArBY,4BAAQ"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts deleted file mode 100644 index cdf77055ed1e..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from './ApiResponse'; -export * from './Category'; -export * from './Order'; -export * from './Pet'; -export * from './Tag'; -export * from './User'; -export declare class ObjectSerializer { - static findCorrectType(data: any, expectedType: string): any; - static serialize(data: any, type: string): any; - static deserialize(data: any, type: string): any; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js deleted file mode 100644 index a5c516ae0ecd..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js +++ /dev/null @@ -1,157 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -Object.defineProperty(exports, "__esModule", { value: true }); -__export(require("./ApiResponse")); -__export(require("./Category")); -__export(require("./Order")); -__export(require("./Pet")); -__export(require("./Tag")); -__export(require("./User")); -var ApiResponse_1 = require("./ApiResponse"); -var Category_1 = require("./Category"); -var Order_1 = require("./Order"); -var Pet_1 = require("./Pet"); -var Tag_1 = require("./Tag"); -var User_1 = require("./User"); -var primitives = [ - "string", - "boolean", - "double", - "integer", - "long", - "float", - "number", - "any" -]; -var enumsMap = { - "Order.StatusEnum": Order_1.Order.StatusEnum, - "Pet.StatusEnum": Pet_1.Pet.StatusEnum, -}; -var typeMap = { - "ApiResponse": ApiResponse_1.ApiResponse, - "Category": Category_1.Category, - "Order": Order_1.Order, - "Pet": Pet_1.Pet, - "Tag": Tag_1.Tag, - "User": User_1.User, -}; -var ObjectSerializer = (function () { - function ObjectSerializer() { - } - ObjectSerializer.findCorrectType = function (data, expectedType) { - if (data == undefined) { - return expectedType; - } - else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { - return expectedType; - } - else if (expectedType === "Date") { - return expectedType; - } - else { - if (enumsMap[expectedType]) { - return expectedType; - } - if (!typeMap[expectedType]) { - return expectedType; - } - var discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { - return expectedType; - } - else { - if (data[discriminatorProperty]) { - var discriminatorType = data[discriminatorProperty]; - if (typeMap[discriminatorType]) { - return discriminatorType; - } - else { - return expectedType; - } - } - else { - return expectedType; - } - } - } - }; - ObjectSerializer.serialize = function (data, type) { - if (data == undefined) { - return data; - } - else if (primitives.indexOf(type.toLowerCase()) !== -1) { - return data; - } - else if (type.lastIndexOf("Array<", 0) === 0) { - var subType = type.replace("Array<", ""); - subType = subType.substring(0, subType.length - 1); - var transformedData = []; - for (var index in data) { - var date = data[index]; - transformedData.push(ObjectSerializer.serialize(date, subType)); - } - return transformedData; - } - else if (type === "Date") { - return data.toISOString(); - } - else { - if (enumsMap[type]) { - return data; - } - if (!typeMap[type]) { - return data; - } - type = this.findCorrectType(data, type); - var attributeTypes = typeMap[type].getAttributeTypeMap(); - var instance = {}; - for (var index in attributeTypes) { - var attributeType = attributeTypes[index]; - instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); - } - return instance; - } - }; - ObjectSerializer.deserialize = function (data, type) { - type = ObjectSerializer.findCorrectType(data, type); - if (data == undefined) { - return data; - } - else if (primitives.indexOf(type.toLowerCase()) !== -1) { - return data; - } - else if (type.lastIndexOf("Array<", 0) === 0) { - var subType = type.replace("Array<", ""); - subType = subType.substring(0, subType.length - 1); - var transformedData = []; - for (var index in data) { - var date = data[index]; - transformedData.push(ObjectSerializer.deserialize(date, subType)); - } - return transformedData; - } - else if (type === "Date") { - return new Date(data); - } - else { - if (enumsMap[type]) { - return data; - } - if (!typeMap[type]) { - return data; - } - var instance = new typeMap[type](); - var attributeTypes = typeMap[type].getAttributeTypeMap(); - for (var index in attributeTypes) { - var attributeType = attributeTypes[index]; - instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); - } - return instance; - } - }; - return ObjectSerializer; -}()); -exports.ObjectSerializer = ObjectSerializer; -//# sourceMappingURL=ObjectSerializer.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map b/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map deleted file mode 100644 index 3adedc52634b..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/ObjectSerializer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ObjectSerializer.js","sourceRoot":"","sources":["../../models/ObjectSerializer.ts"],"names":[],"mappings":";;;;;AAAA,mCAA8B;AAC9B,gCAA2B;AAC3B,6BAAwB;AACxB,2BAAsB;AACtB,2BAAsB;AACtB,4BAAuB;AAEvB,6CAA4C;AAC5C,uCAAsC;AACtC,iCAAgC;AAChC,6BAA4B;AAC5B,6BAA4B;AAC5B,+BAA8B;AAG9B,IAAI,UAAU,GAAG;IACG,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;IACP,QAAQ;IACR,KAAK;CACP,CAAC;AAEnB,IAAI,QAAQ,GAA2B;IAC/B,kBAAkB,EAAE,aAAK,CAAC,UAAU;IACpC,gBAAgB,EAAE,SAAG,CAAC,UAAU;CACvC,CAAA;AAED,IAAI,OAAO,GAA2B;IAClC,aAAa,EAAE,yBAAW;IAC1B,UAAU,EAAE,mBAAQ;IACpB,OAAO,EAAE,aAAK;IACd,KAAK,EAAE,SAAG;IACV,KAAK,EAAE,SAAG;IACV,MAAM,EAAE,WAAI;CACf,CAAA;AAED;IAAA;IA6GA,CAAC;IA5GiB,gCAAe,GAA7B,UAA8B,IAAS,EAAE,YAAoB;QACzD,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,YAAY,CAAC;SACvB;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YAC9D,OAAO,YAAY,CAAC;SACvB;aAAM,IAAI,YAAY,KAAK,MAAM,EAAE;YAChC,OAAO,YAAY,CAAC;SACvB;aAAM;YACH,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE;gBACxB,OAAO,YAAY,CAAC;aACvB;YAED,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;gBACxB,OAAO,YAAY,CAAC;aACvB;YAGD,IAAI,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC;YAChE,IAAI,qBAAqB,IAAI,IAAI,EAAE;gBAC/B,OAAO,YAAY,CAAC;aACvB;iBAAM;gBACH,IAAI,IAAI,CAAC,qBAAqB,CAAC,EAAE;oBAC7B,IAAI,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC;oBACpD,IAAG,OAAO,CAAC,iBAAiB,CAAC,EAAC;wBAC1B,OAAO,iBAAiB,CAAC;qBAC5B;yBAAM;wBACH,OAAO,YAAY,CAAC;qBACvB;iBACJ;qBAAM;oBACH,OAAO,YAAY,CAAC;iBACvB;aACJ;SACJ;IACL,CAAC;IAEa,0BAAS,GAAvB,UAAwB,IAAS,EAAE,IAAY;QAC3C,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YAC5C,IAAI,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,eAAe,GAAU,EAAE,CAAC;YAChC,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE;gBACpB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;aACnE;YACD,OAAO,eAAe,CAAC;SAC1B;aAAM,IAAI,IAAI,KAAK,MAAM,EAAE;YACxB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;aAAM;YACH,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YAGD,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAGxC,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;YACzD,IAAI,QAAQ,GAA2B,EAAE,CAAC;YAC1C,KAAK,IAAI,KAAK,IAAI,cAAc,EAAE;gBAC9B,IAAI,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBAC1C,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC/G;YACD,OAAO,QAAQ,CAAC;SACnB;IACL,CAAC;IAEa,4BAAW,GAAzB,UAA0B,IAAS,EAAE,IAAY;QAE7C,IAAI,GAAG,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,IAAI,IAAI,SAAS,EAAE;YACnB,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC;SACf;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YAC5C,IAAI,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,eAAe,GAAU,EAAE,CAAC;YAChC,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE;gBACpB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;aACrE;YACD,OAAO,eAAe,CAAC;SAC1B;aAAM,IAAI,IAAI,KAAK,MAAM,EAAE;YACxB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;aAAM;YACH,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,QAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;YACzD,KAAK,IAAI,KAAK,IAAI,cAAc,EAAE;gBAC9B,IAAI,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBAC1C,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aACjH;YACD,OAAO,QAAQ,CAAC;SACnB;IACL,CAAC;IACL,uBAAC;AAAD,CAAC,AA7GD,IA6GC;AA7GY,4CAAgB"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts deleted file mode 100644 index 49771cf1b5b7..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Order.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export declare class Order { - 'id'?: number; - 'petId'?: number; - 'quantity'?: number; - 'shipDate'?: Date; - 'status'?: Order.StatusEnum; - 'complete'?: boolean; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} -export declare namespace Order { - enum StatusEnum { - Placed, - Approved, - Delivered - } -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.js b/samples/client/petstore/typescript/builds/default/dist/models/Order.js deleted file mode 100644 index ff531f4ff002..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Order.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Order = (function () { - function Order() { - } - Order.getAttributeTypeMap = function () { - return Order.attributeTypeMap; - }; - Order.discriminator = undefined; - Order.attributeTypeMap = [ - { - "name": "id", - "baseName": "id", - "type": "number" - }, - { - "name": "petId", - "baseName": "petId", - "type": "number" - }, - { - "name": "quantity", - "baseName": "quantity", - "type": "number" - }, - { - "name": "shipDate", - "baseName": "shipDate", - "type": "Date" - }, - { - "name": "status", - "baseName": "status", - "type": "Order.StatusEnum" - }, - { - "name": "complete", - "baseName": "complete", - "type": "boolean" - } - ]; - return Order; -}()); -exports.Order = Order; -(function (Order) { - var StatusEnum; - (function (StatusEnum) { - StatusEnum[StatusEnum["Placed"] = 'placed'] = "Placed"; - StatusEnum[StatusEnum["Approved"] = 'approved'] = "Approved"; - StatusEnum[StatusEnum["Delivered"] = 'delivered'] = "Delivered"; - })(StatusEnum = Order.StatusEnum || (Order.StatusEnum = {})); -})(Order = exports.Order || (exports.Order = {})); -exports.Order = Order; -//# sourceMappingURL=Order.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map deleted file mode 100644 index 6e0842825dbe..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Order.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Order.js","sourceRoot":"","sources":["../../models/Order.ts"],"names":[],"mappings":";;AAOA;IAAA;IAgDA,CAAC;IAHU,yBAAmB,GAA1B;QACI,OAAO,KAAK,CAAC,gBAAgB,CAAC;IAClC,CAAC;IApCM,mBAAa,GAAuB,SAAS,CAAC;IAE9C,sBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,MAAM;SACjB;QACD;YACI,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,kBAAkB;SAC7B;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,SAAS;SACpB;KAAK,CAAC;IAKf,YAAC;CAAA,AAhDD,IAgDC;AAhDY,sBAAK;AAkDlB,WAAiB,KAAK;IAClB,IAAY,UAIX;IAJD,WAAY,UAAU;QAClB,kCAAe,QAAQ,YAAA,CAAA;QACvB,oCAAiB,UAAU,cAAA,CAAA;QAC3B,qCAAkB,WAAW,eAAA,CAAA;IACjC,CAAC,EAJW,UAAU,GAAV,gBAAU,KAAV,gBAAU,QAIrB;AACL,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAMrB;AAxDY,sBAAK"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts deleted file mode 100644 index 1d2a7e3fc0a0..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Pet.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Category } from './Category'; -import { Tag } from './Tag'; -export declare class Pet { - 'id'?: number; - 'category'?: Category; - 'name': string; - 'photoUrls': Array; - 'tags'?: Array; - 'status'?: Pet.StatusEnum; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} -export declare namespace Pet { - enum StatusEnum { - Available, - Pending, - Sold - } -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js deleted file mode 100644 index 9fb032b04e30..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Pet = (function () { - function Pet() { - } - Pet.getAttributeTypeMap = function () { - return Pet.attributeTypeMap; - }; - Pet.discriminator = undefined; - Pet.attributeTypeMap = [ - { - "name": "id", - "baseName": "id", - "type": "number" - }, - { - "name": "category", - "baseName": "category", - "type": "Category" - }, - { - "name": "name", - "baseName": "name", - "type": "string" - }, - { - "name": "photoUrls", - "baseName": "photoUrls", - "type": "Array" - }, - { - "name": "tags", - "baseName": "tags", - "type": "Array" - }, - { - "name": "status", - "baseName": "status", - "type": "Pet.StatusEnum" - } - ]; - return Pet; -}()); -exports.Pet = Pet; -(function (Pet) { - var StatusEnum; - (function (StatusEnum) { - StatusEnum[StatusEnum["Available"] = 'available'] = "Available"; - StatusEnum[StatusEnum["Pending"] = 'pending'] = "Pending"; - StatusEnum[StatusEnum["Sold"] = 'sold'] = "Sold"; - })(StatusEnum = Pet.StatusEnum || (Pet.StatusEnum = {})); -})(Pet = exports.Pet || (exports.Pet = {})); -exports.Pet = Pet; -//# sourceMappingURL=Pet.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map deleted file mode 100644 index fb14e0801b53..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Pet.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Pet.js","sourceRoot":"","sources":["../../models/Pet.ts"],"names":[],"mappings":";;AASA;IAAA;IAgDA,CAAC;IAHU,uBAAmB,GAA1B;QACI,OAAO,GAAG,CAAC,gBAAgB,CAAC;IAChC,CAAC;IApCM,iBAAa,GAAuB,SAAS,CAAC;IAE9C,oBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,UAAU;SACrB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,eAAe;SAC1B;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,YAAY;SACvB;QACD;YACI,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,gBAAgB;SAC3B;KAAK,CAAC;IAKf,UAAC;CAAA,AAhDD,IAgDC;AAhDY,kBAAG;AAkDhB,WAAiB,GAAG;IAChB,IAAY,UAIX;IAJD,WAAY,UAAU;QAClB,qCAAkB,WAAW,eAAA,CAAA;QAC7B,mCAAgB,SAAS,aAAA,CAAA;QACzB,gCAAa,MAAM,UAAA,CAAA;IACvB,CAAC,EAJW,UAAU,GAAV,cAAU,KAAV,cAAU,QAIrB;AACL,CAAC,EANgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAMnB;AAxDY,kBAAG"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts deleted file mode 100644 index 67bc2920f9dd..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Tag.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare class Tag { - 'id'?: number; - 'name'?: string; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js deleted file mode 100644 index 87e09817f366..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Tag = (function () { - function Tag() { - } - Tag.getAttributeTypeMap = function () { - return Tag.attributeTypeMap; - }; - Tag.discriminator = undefined; - Tag.attributeTypeMap = [ - { - "name": "id", - "baseName": "id", - "type": "number" - }, - { - "name": "name", - "baseName": "name", - "type": "string" - } - ]; - return Tag; -}()); -exports.Tag = Tag; -//# sourceMappingURL=Tag.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map b/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map deleted file mode 100644 index 03ee391c2a2d..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/Tag.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../models/Tag.ts"],"names":[],"mappings":";;AAOA;IAAA;IAqBA,CAAC;IAHU,uBAAmB,GAA1B;QACI,OAAO,GAAG,CAAC,gBAAgB,CAAC;IAChC,CAAC;IAhBM,iBAAa,GAAuB,SAAS,CAAC;IAE9C,oBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,UAAC;CAAA,AArBD,IAqBC;AArBY,kBAAG"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts b/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts deleted file mode 100644 index 6bad8680ad29..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/User.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export declare class User { - 'id'?: number; - 'username'?: string; - 'firstName'?: string; - 'lastName'?: string; - 'email'?: string; - 'password'?: string; - 'phone'?: string; - 'userStatus'?: number; - static discriminator: string | undefined; - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }>; - static getAttributeTypeMap(): { - name: string; - baseName: string; - type: string; - }[]; -} diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.js b/samples/client/petstore/typescript/builds/default/dist/models/User.js deleted file mode 100644 index a2d431b5e89d..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/User.js +++ /dev/null @@ -1,55 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var User = (function () { - function User() { - } - User.getAttributeTypeMap = function () { - return User.attributeTypeMap; - }; - User.discriminator = undefined; - User.attributeTypeMap = [ - { - "name": "id", - "baseName": "id", - "type": "number" - }, - { - "name": "username", - "baseName": "username", - "type": "string" - }, - { - "name": "firstName", - "baseName": "firstName", - "type": "string" - }, - { - "name": "lastName", - "baseName": "lastName", - "type": "string" - }, - { - "name": "email", - "baseName": "email", - "type": "string" - }, - { - "name": "password", - "baseName": "password", - "type": "string" - }, - { - "name": "phone", - "baseName": "phone", - "type": "string" - }, - { - "name": "userStatus", - "baseName": "userStatus", - "type": "number" - } - ]; - return User; -}()); -exports.User = User; -//# sourceMappingURL=User.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/models/User.js.map b/samples/client/petstore/typescript/builds/default/dist/models/User.js.map deleted file mode 100644 index 3bb95d7da848..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/models/User.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"User.js","sourceRoot":"","sources":["../../models/User.ts"],"names":[],"mappings":";;AAOA;IAAA;IA4DA,CAAC;IAHU,wBAAmB,GAA1B;QACI,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IA9CM,kBAAa,GAAuB,SAAS,CAAC;IAE9C,qBAAgB,GAA0D;QAC7E;YACI,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,UAAU;YACtB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,QAAQ;SACnB;QACD;YACI,MAAM,EAAE,YAAY;YACpB,UAAU,EAAE,YAAY;YACxB,MAAM,EAAE,QAAQ;SACnB;KAAK,CAAC;IAKf,WAAC;CAAA,AA5DD,IA4DC;AA5DY,oBAAI"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.d.ts b/samples/client/petstore/typescript/builds/default/dist/servers.d.ts deleted file mode 100644 index 4b73dab5d806..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/servers.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RequestContext, HttpMethod } from './http/http'; -export declare class ServerConfiguration { - private url; - constructor(url: string); - makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; -} -export declare const servers: ServerConfiguration[]; diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.js b/samples/client/petstore/typescript/builds/default/dist/servers.js deleted file mode 100644 index 8ed43ec5a3c5..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/servers.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var http_1 = require("./http/http"); -var ServerConfiguration = (function () { - function ServerConfiguration(url) { - this.url = url; - } - ServerConfiguration.prototype.makeRequestContext = function (endpoint, httpMethod) { - return new http_1.RequestContext(this.url + endpoint, httpMethod); - }; - return ServerConfiguration; -}()); -exports.ServerConfiguration = ServerConfiguration; -exports.servers = [ - new ServerConfiguration("http://petstore.swagger.io/v2"), -]; -//# sourceMappingURL=servers.js.map \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/dist/servers.js.map b/samples/client/petstore/typescript/builds/default/dist/servers.js.map deleted file mode 100644 index 25d3c604ee57..000000000000 --- a/samples/client/petstore/typescript/builds/default/dist/servers.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"servers.js","sourceRoot":"","sources":["../servers.ts"],"names":[],"mappings":";;AAAA,oCAAuD;AAEvD;IAEI,6BAA2B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IACtC,CAAC;IAEG,gDAAkB,GAAzB,UAA0B,QAAgB,EAAE,UAAsB;QACjE,OAAO,IAAI,qBAAc,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IACF,0BAAC;AAAD,CAAC,AARD,IAQC;AARY,kDAAmB;AAUnB,QAAA,OAAO,GAAG;IACtB,IAAI,mBAAmB,CAAC,+BAA+B,CAAC;CACxD,CAAA"} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index dd200043238c..d0c749992b4d 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -6,6 +6,7 @@ import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Promise { + console.log("Request: ", request); let method = request.getHttpMethod().toString(); let body = request.getBody(); @@ -21,7 +22,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { headers[key] = (headers[key] as Array).join("; "); } - return resp.text().then((body) => { + return resp.json().then((body) => { return new ResponseContext(resp.status, headers, body) }); }); diff --git a/samples/client/petstore/typescript/builds/default/models/all.ts b/samples/client/petstore/typescript/builds/default/models/all.ts new file mode 100644 index 000000000000..2edba7f0bd56 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/all.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse' +export * from './Category' +export * from './Order' +export * from './Pet' +export * from './Tag' +export * from './User' diff --git a/samples/client/petstore/typescript/builds/default/test.ts b/samples/client/petstore/typescript/builds/default/test.ts new file mode 100644 index 000000000000..8ed9bc4498aa --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/test.ts @@ -0,0 +1,12 @@ +import {PetApi} from './api'; +import {Configuration } from './configuration'; + +const config = new Configuration(); +const api = new PetApi(config); + +api.getPetById(3).then((pet) => { + console.log(pet) +}).catch((err) => { + +console.log(err); +}); From a7de49110ea3413b46e21779b30f8d28852e9b14 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 17 Oct 2018 16:38:44 +0200 Subject: [PATCH 13/85] Ignore dist folder in typescript client sample --- samples/client/petstore/typescript/builds/default/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 samples/client/petstore/typescript/builds/default/.gitignore diff --git a/samples/client/petstore/typescript/builds/default/.gitignore b/samples/client/petstore/typescript/builds/default/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/.gitignore @@ -0,0 +1 @@ +dist From 61a1bbdabec52d783fa75a4eabc1756b5a033acd Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 17 Oct 2018 16:51:56 +0200 Subject: [PATCH 14/85] Added middleware to fetch --- .../generators/fetch/fetch.mustache | 19 +- .../typescript/http/isomorphic-fetch.mustache | 1 - .../resources/typescript/middleware.mustache | 4 +- .../petstore/typescript/builds/default/api.ts | 380 ++++++++++++++---- .../builds/default/http/isomorphic-fetch.ts | 1 - .../typescript/builds/default/middleware.ts | 4 +- .../typescript/builds/default/test.ts | 24 +- 7 files changed, 340 insertions(+), 93 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache index 9fe4b31ba5e0..5198b5d89c6f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache @@ -24,10 +24,21 @@ export class {{classname}} { {{#operation}} public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.{{nickname}}(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.{{nickname}}(rsp)); + }); } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index d0c749992b4d..42573484beab 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -6,7 +6,6 @@ import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Promise { - console.log("Request: ", request); let method = request.getHttpMethod().toString(); let body = request.getBody(); diff --git a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache index 782cddb321c9..3ac072bab22c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/middleware.mustache @@ -1,8 +1,8 @@ import {RequestContext, ResponseContext} from './http/http'; export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; + pre(context: RequestContext): Promise; + post(context: ResponseContext): Promise; } // TODO: package.json set npmName \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/api.ts b/samples/client/petstore/typescript/builds/default/api.ts index f3006877b921..ffce3d9bf4ed 100644 --- a/samples/client/petstore/typescript/builds/default/api.ts +++ b/samples/client/petstore/typescript/builds/default/api.ts @@ -21,66 +21,154 @@ export class PetApi { public addPet(pet: Pet, options?: any): Promise { const requestContext = this.requestFactory.addPet(pet, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.addPet(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.addPet(rsp)); + }); } public deletePet(petId: number, apiKey?: string, options?: any): Promise { const requestContext = this.requestFactory.deletePet(petId, apiKey, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.deletePet(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.deletePet(rsp)); + }); } public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise> { const requestContext = this.requestFactory.findPetsByStatus(status, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.findPetsByStatus(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.findPetsByStatus(rsp)); + }); } public findPetsByTags(tags: Array, options?: any): Promise> { const requestContext = this.requestFactory.findPetsByTags(tags, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.findPetsByTags(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.findPetsByTags(rsp)); + }); } public getPetById(petId: number, options?: any): Promise { const requestContext = this.requestFactory.getPetById(petId, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.getPetById(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.getPetById(rsp)); + }); } public updatePet(pet: Pet, options?: any): Promise { const requestContext = this.requestFactory.updatePet(pet, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.updatePet(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.updatePet(rsp)); + }); } public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise { const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.updatePetWithForm(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.updatePetWithForm(rsp)); + }); } public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.uploadFile(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.uploadFile(rsp)); + }); } @@ -101,34 +189,78 @@ export class StoreApi { public deleteOrder(orderId: string, options?: any): Promise { const requestContext = this.requestFactory.deleteOrder(orderId, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.deleteOrder(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.deleteOrder(rsp)); + }); } public getInventory(options?: any): Promise<{ [key: string]: number; }> { const requestContext = this.requestFactory.getInventory(options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.getInventory(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.getInventory(rsp)); + }); } public getOrderById(orderId: number, options?: any): Promise { const requestContext = this.requestFactory.getOrderById(orderId, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.getOrderById(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.getOrderById(rsp)); + }); } public placeOrder(order: Order, options?: any): Promise { const requestContext = this.requestFactory.placeOrder(order, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.placeOrder(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.placeOrder(rsp)); + }); } @@ -149,66 +281,154 @@ export class UserApi { public createUser(user: User, options?: any): Promise { const requestContext = this.requestFactory.createUser(user, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.createUser(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.createUser(rsp)); + }); } public createUsersWithArrayInput(user: Array, options?: any): Promise { const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.createUsersWithArrayInput(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.createUsersWithArrayInput(rsp)); + }); } public createUsersWithListInput(user: Array, options?: any): Promise { const requestContext = this.requestFactory.createUsersWithListInput(user, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.createUsersWithListInput(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.createUsersWithListInput(rsp)); + }); } public deleteUser(username: string, options?: any): Promise { const requestContext = this.requestFactory.deleteUser(username, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.deleteUser(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.deleteUser(rsp)); + }); } public getUserByName(username: string, options?: any): Promise { const requestContext = this.requestFactory.getUserByName(username, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.getUserByName(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.getUserByName(rsp)); + }); } public loginUser(username: string, password: string, options?: any): Promise { const requestContext = this.requestFactory.loginUser(username, password, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.loginUser(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.loginUser(rsp)); + }); } public logoutUser(options?: any): Promise { const requestContext = this.requestFactory.logoutUser(options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.logoutUser(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.logoutUser(rsp)); + }); } public updateUser(username: string, user: User, options?: any): Promise { const requestContext = this.requestFactory.updateUser(username, user, options); - - return this.configuration.httpApi.send(requestContext).then((response: ResponseContext) => { - return this.responseProcessor.updateUser(response); - }); + + // build promise chain + let middlewarePrePromise =Promise.resolve(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + } + + return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). + then((response: ResponseContext) => { + let middlewarePostPromise = Promise.resolve(response); + for (let middleware of this.configuration.middleware) { + middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + } + return middlewarePostPromise.then((rsp) => this.responseProcessor.updateUser(rsp)); + }); } diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index d0c749992b4d..42573484beab 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -6,7 +6,6 @@ import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Promise { - console.log("Request: ", request); let method = request.getHttpMethod().toString(); let body = request.getBody(); diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index 782cddb321c9..3ac072bab22c 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -1,8 +1,8 @@ import {RequestContext, ResponseContext} from './http/http'; export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; + pre(context: RequestContext): Promise; + post(context: ResponseContext): Promise; } // TODO: package.json set npmName \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/test.ts b/samples/client/petstore/typescript/builds/default/test.ts index 8ed9bc4498aa..fa5ff91a9545 100644 --- a/samples/client/petstore/typescript/builds/default/test.ts +++ b/samples/client/petstore/typescript/builds/default/test.ts @@ -1,12 +1,30 @@ import {PetApi} from './api'; import {Configuration } from './configuration'; +import { Middleware } from './middleware'; +import { RequestContext, ResponseContext } from './http/http'; -const config = new Configuration(); +class MiddlewareA implements Middleware { + + public pre(request: RequestContext) { + console.log(request); + return Promise.resolve(request); + } + + public post(response: ResponseContext) { + console.log(response) + return Promise.resolve(response); + } +} + +const config = new Configuration({ + middleware: [ + new MiddlewareA() + ] +}); const api = new PetApi(config); api.getPetById(3).then((pet) => { console.log(pet) }).catch((err) => { - -console.log(err); + console.log(err); }); From a6560e553037f538f7a9828d3db807d32dd793c3 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 17 Oct 2018 17:10:14 +0200 Subject: [PATCH 15/85] Restructured TypeScript generator --- .../languages/TypeScriptClientCodegen.java | 19 +++++++++--------- .../{ => api}/ObjectSerializer.mustache | 0 .../typescript/{ => api}/api.mustache | 0 .../typescript/{ => api}/baseapi.mustache | 0 .../typescript/{ => api}/middleware.mustache | 0 .../fetch.mustache => PromiseAPI.mustache} | 0 .../generators/fetch/index.mustache | 6 ++++++ .../typescript/{ => http}/servers.mustache | 0 .../main/resources/typescript/index.mustache | 9 --------- .../typescript/{ => model}/model.mustache | 0 .../{ => model}/models_all.mustache | 0 .../builds/default/{api.ts => PromiseAPI.ts} | 0 .../typescript/builds/default/index.ts | 9 +++------ .../builds/default/package-lock.json | 20 +++++++++---------- .../typescript/builds/default/test.ts | 2 +- 15 files changed, 30 insertions(+), 35 deletions(-) rename modules/openapi-generator/src/main/resources/typescript/{ => api}/ObjectSerializer.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{ => api}/api.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{ => api}/baseapi.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{ => api}/middleware.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/generators/{fetch/fetch.mustache => PromiseAPI.mustache} (100%) create mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache rename modules/openapi-generator/src/main/resources/typescript/{ => http}/servers.mustache (100%) delete mode 100644 modules/openapi-generator/src/main/resources/typescript/index.mustache rename modules/openapi-generator/src/main/resources/typescript/{ => model}/model.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{ => model}/models_all.mustache (100%) rename samples/client/petstore/typescript/builds/default/{api.ts => PromiseAPI.ts} (100%) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 12687fb5ba87..b6ad78e13ef9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -124,26 +124,27 @@ public TypeScriptClientCodegen() { // http supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts")); + supportingFiles.add(new SupportingFile("http/servers.mustache", "servers.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); - supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts")); supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); - supportingFiles.add(new SupportingFile("servers.mustache", "servers.ts")); - supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); - supportingFiles.add(new SupportingFile("models_all.mustache", "models", "all.ts")); + supportingFiles.add(new SupportingFile("model/models_all.mustache", "models", "all.ts")); // TODO: add supporting files depending on cli parameter e.g. fetch vs angular - supportingFiles.add(new SupportingFile("generators/fetch/fetch.mustache", "api.ts")); + supportingFiles.add(new SupportingFile("generators/PromiseAPI.mustache", "PromiseAPI.ts")); + supportingFiles.add(new SupportingFile("generators/fetch/index.mustache", "index.ts")); + // models // TODO: properly set model and api packages this.setModelPackage(""); - supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); - modelTemplateFiles.put("model.mustache", ".ts"); + supportingFiles.add(new SupportingFile("api/ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); + modelTemplateFiles.put("model/model.mustache", ".ts"); // api this.setApiPackage(""); - this.supportingFiles.add(new SupportingFile("baseapi.mustache", "apis", "baseapi.ts")); - this.apiTemplateFiles.put("api.mustache", ".ts"); + supportingFiles.add(new SupportingFile("api/middleware.mustache", "", "middleware.ts")); + this.supportingFiles.add(new SupportingFile("api/baseapi.mustache", "apis", "baseapi.ts")); + this.apiTemplateFiles.put("api/api.mustache", ".ts"); } diff --git a/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/api/ObjectSerializer.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache rename to modules/openapi-generator/src/main/resources/typescript/api/ObjectSerializer.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/api.mustache rename to modules/openapi-generator/src/main/resources/typescript/api/api.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache b/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/baseapi.mustache rename to modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/middleware.mustache rename to modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/generators/fetch/fetch.mustache rename to modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache new file mode 100644 index 000000000000..7ca470aa17cf --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache @@ -0,0 +1,6 @@ +export * from './http/http'; +export * from './auth/auth'; +export * from './middleware'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './PromiseAPI'; diff --git a/modules/openapi-generator/src/main/resources/typescript/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/servers.mustache rename to modules/openapi-generator/src/main/resources/typescript/http/servers.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache deleted file mode 100644 index 507c0bf9283d..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ /dev/null @@ -1,9 +0,0 @@ -export * from './configuration' -export * from './http/http'; -export * from './auth/auth'; -export * from './middleware'; -export * from './servers'; -// TODO: export models, export API - -// TODO: make this export conditional => only if isomorphic-fetch is included -export * from './http/isomorphic-fetch'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/model.mustache rename to modules/openapi-generator/src/main/resources/typescript/model/model.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/models_all.mustache b/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/models_all.mustache rename to modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache diff --git a/samples/client/petstore/typescript/builds/default/api.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/api.ts rename to samples/client/petstore/typescript/builds/default/PromiseAPI.ts diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index 507c0bf9283d..7ca470aa17cf 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,9 +1,6 @@ -export * from './configuration' export * from './http/http'; export * from './auth/auth'; export * from './middleware'; -export * from './servers'; -// TODO: export models, export API - -// TODO: make this export conditional => only if isomorphic-fetch is included -export * from './http/isomorphic-fetch'; \ No newline at end of file +export * from './models/all'; +export { Configuration} from './configuration' +export * from './PromiseAPI'; diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index 6e51be4ad1cc..c11426a6fc0e 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -30,9 +30,9 @@ "dev": true }, "@types/node": { - "version": "10.11.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.7.tgz", - "integrity": "sha512-yOxFfkN9xUFLyvWaeYj90mlqTJ41CsQzWKS3gXdOMOyPVacUsymejKxJ4/pMW7exouubuEeZLJawGgcNGYlTeg==" + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" }, "arrify": { "version": "1.0.1", @@ -105,9 +105,9 @@ "dev": true }, "combined-stream": { - "version": "1.0.6", - "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { "delayed-stream": "~1.0.0" } @@ -173,12 +173,12 @@ "dev": true }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, diff --git a/samples/client/petstore/typescript/builds/default/test.ts b/samples/client/petstore/typescript/builds/default/test.ts index fa5ff91a9545..84720175224b 100644 --- a/samples/client/petstore/typescript/builds/default/test.ts +++ b/samples/client/petstore/typescript/builds/default/test.ts @@ -1,4 +1,4 @@ -import {PetApi} from './api'; +import {PetApi} from './index'; import {Configuration } from './configuration'; import { Middleware } from './middleware'; import { RequestContext, ResponseContext } from './http/http'; From 7909cbaec7f7f7f5172524400a61a740859884a8 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 17 Oct 2018 17:36:41 +0200 Subject: [PATCH 16/85] Reverted: http library.send returns string again --- .../resources/typescript/api/api.mustache | 3 +- .../generators/fetch/index.mustache | 1 + .../typescript/http/isomorphic-fetch.mustache | 2 +- .../resources/typescript/package.mustache | 7 +- .../typescript/builds/default/apis/PetApi.ts | 16 +- .../builds/default/apis/StoreApi.ts | 10 +- .../typescript/builds/default/apis/UserApi.ts | 12 +- .../builds/default/http/isomorphic-fetch.ts | 2 +- .../typescript/builds/default/index.ts | 1 + .../builds/default/package-lock.json | 317 --------------- .../typescript/builds/default/package.json | 7 +- .../tests/default/dist/auth/auth.test.js | 6 +- .../dist/http/isomorphic-fetch.test.js | 3 +- .../typescript/tests/default/dist/test.js | 27 ++ .../tests/default/dist/test/auth/auth.test.js | 46 +++ .../dist/test/http/isomorphic-fetch.test.js | 64 +++ .../tests/default/package-lock.json | 374 ++++-------------- .../{builds => tests}/default/test.ts | 5 +- .../tests/default/test/auth/auth.test.ts | 6 +- .../test/http/isomorphic-fetch.test.ts | 3 +- 20 files changed, 258 insertions(+), 654 deletions(-) create mode 100644 samples/client/petstore/typescript/tests/default/dist/test.js create mode 100644 samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js create mode 100644 samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js rename samples/client/petstore/typescript/{builds => tests}/default/test.ts (71%) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 24bc3c775a90..8e88ae4e6910 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -118,9 +118,10 @@ export class {{classname}}ResponseProcessor { * @throws {{{returnType}}} if the httpStatusCode is not in [200, 299] */ public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; {{#returnType}} - const body: {{{returnType}}} = ObjectSerializer.deserialize(response.body, "{{{returnType}}}") as {{{returnType}}}; + const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}") as {{{returnType}}}; if (responseOK) { return body; } else { diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache index 7ca470aa17cf..2bcea78b8ca8 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache @@ -1,4 +1,5 @@ export * from './http/http'; +export { IsomorphicFetchHttpLibrary } from './http/isomorphic-fetch'; export * from './auth/auth'; export * from './middleware'; export * from './models/all'; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index 42573484beab..b62f68418d35 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -21,7 +21,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { headers[key] = (headers[key] as Array).join("; "); } - return resp.json().then((body) => { + return resp.text().then((body: string) => { return new ResponseContext(resp.status, headers, body) }); }); diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 7fe4daed3e96..000086e2010f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -27,12 +27,7 @@ "url-parse": "^1.4.3" }, "devDependencies": { - "ts-node": "^7.0.0", - "typescript": "^2.9.2", - "@types/chai": "^4.1.4", - "@types/mocha": "^5.2.5", - "chai": "^4.1.2", - "mocha": "^5.2.0" + "typescript": "^2.9.2" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig":{ diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 08ae13543576..75deb2c89f12 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -321,6 +321,7 @@ export class PetApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public addPet(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -333,6 +334,7 @@ export class PetApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public deletePet(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -345,8 +347,9 @@ export class PetApiResponseProcessor { * @throws Array if the httpStatusCode is not in [200, 299] */ public findPetsByStatus(response: ResponseContext): Array { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Array = ObjectSerializer.deserialize(response.body, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; if (responseOK) { return body; } else { @@ -360,8 +363,9 @@ export class PetApiResponseProcessor { * @throws Array if the httpStatusCode is not in [200, 299] */ public findPetsByTags(response: ResponseContext): Array { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Array = ObjectSerializer.deserialize(response.body, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; if (responseOK) { return body; } else { @@ -375,8 +379,9 @@ export class PetApiResponseProcessor { * @throws Pet if the httpStatusCode is not in [200, 299] */ public getPetById(response: ResponseContext): Pet { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Pet = ObjectSerializer.deserialize(response.body, "Pet") as Pet; + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; if (responseOK) { return body; } else { @@ -390,6 +395,7 @@ export class PetApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public updatePet(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -402,6 +408,7 @@ export class PetApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public updatePetWithForm(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -414,8 +421,9 @@ export class PetApiResponseProcessor { * @throws ApiResponse if the httpStatusCode is not in [200, 299] */ public uploadFile(response: ResponseContext): ApiResponse { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: ApiResponse = ObjectSerializer.deserialize(response.body, "ApiResponse") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; if (responseOK) { return body; } else { diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index f3d7a4b1ad72..3445cbf2ebfe 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -137,6 +137,7 @@ export class StoreApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public deleteOrder(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -149,8 +150,9 @@ export class StoreApiResponseProcessor { * @throws { [key: string]: number; } if the httpStatusCode is not in [200, 299] */ public getInventory(response: ResponseContext): { [key: string]: number; } { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: { [key: string]: number; } = ObjectSerializer.deserialize(response.body, "{ [key: string]: number; }") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; if (responseOK) { return body; } else { @@ -164,8 +166,9 @@ export class StoreApiResponseProcessor { * @throws Order if the httpStatusCode is not in [200, 299] */ public getOrderById(response: ResponseContext): Order { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Order = ObjectSerializer.deserialize(response.body, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; if (responseOK) { return body; } else { @@ -179,8 +182,9 @@ export class StoreApiResponseProcessor { * @throws Order if the httpStatusCode is not in [200, 299] */ public placeOrder(response: ResponseContext): Order { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Order = ObjectSerializer.deserialize(response.body, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; if (responseOK) { return body; } else { diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index dc2b564e4238..ebb1c357f1d0 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -275,6 +275,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public createUser(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -287,6 +288,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public createUsersWithArrayInput(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -299,6 +301,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public createUsersWithListInput(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -311,6 +314,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public deleteUser(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -323,8 +327,9 @@ export class UserApiResponseProcessor { * @throws User if the httpStatusCode is not in [200, 299] */ public getUserByName(response: ResponseContext): User { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: User = ObjectSerializer.deserialize(response.body, "User") as User; + const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; if (responseOK) { return body; } else { @@ -338,8 +343,9 @@ export class UserApiResponseProcessor { * @throws string if the httpStatusCode is not in [200, 299] */ public loginUser(response: ResponseContext): string { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: string = ObjectSerializer.deserialize(response.body, "string") as string; + const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; if (responseOK) { return body; } else { @@ -353,6 +359,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public logoutUser(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { @@ -365,6 +372,7 @@ export class UserApiResponseProcessor { * @throws if the httpStatusCode is not in [200, 299] */ public updateUser(response: ResponseContext): void { + const jsonBody = JSON.parse(response.body); const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; // TODO: make this based on status code! if (!responseOK) { diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index 42573484beab..b62f68418d35 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -21,7 +21,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { headers[key] = (headers[key] as Array).join("; "); } - return resp.json().then((body) => { + return resp.text().then((body: string) => { return new ResponseContext(resp.status, headers, body) }); }); diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index 7ca470aa17cf..2bcea78b8ca8 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,4 +1,5 @@ export * from './http/http'; +export { IsomorphicFetchHttpLibrary } from './http/isomorphic-fetch'; export * from './auth/auth'; export * from './middleware'; export * from './models/all'; diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index c11426a6fc0e..331f3c78d71d 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -4,12 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/chai": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", - "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", - "dev": true - }, "@types/form-data": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", @@ -23,87 +17,21 @@ "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" }, - "@types/mocha": { - "version": "5.2.5", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", - "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", - "dev": true - }, "@types/node": { "version": "10.12.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, "btoa": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "chai": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", - "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, "combined-stream": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", @@ -112,47 +40,11 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.15.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, "encoding": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", @@ -166,12 +58,6 @@ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, "form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", @@ -182,50 +68,6 @@ "mime-types": "^2.1.12" } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -234,22 +76,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -264,12 +90,6 @@ "whatwg-fetch": ">=0.10.0" } }, - "make-error": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", - "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", - "dev": true - }, "mime-db": { "version": "1.36.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", @@ -283,55 +103,6 @@ "mime-db": "~1.36.0" } }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, "node-fetch": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", @@ -341,27 +112,6 @@ "is-stream": "^1.0.1" } }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, "querystringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", @@ -377,61 +127,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "source-map-support": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", - "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "ts-node": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", - "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", - "dev": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", @@ -451,18 +146,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", - "dev": true } } } diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index e09caae835ad..7ffb1436e084 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -27,11 +27,6 @@ "url-parse": "^1.4.3" }, "devDependencies": { - "ts-node": "^7.0.0", - "typescript": "^2.9.2", - "@types/chai": "^4.1.4", - "@types/mocha": "^5.2.5", - "chai": "^4.1.2", - "mocha": "^5.2.0" + "typescript": "^2.9.2" } } diff --git a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js index 6cf65e3d7acf..e0e55de464a6 100644 --- a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js +++ b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js @@ -18,7 +18,7 @@ describe("Security Authentication", function () { // TODO: make all params const variables it("Header API Key", function () { var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "header"); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); auth.applySecurityAuthentication(ctx); chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); @@ -27,7 +27,7 @@ describe("Security Authentication", function () { }); it("Query API Key", function () { var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "query"); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "query", "apiKey"); auth.applySecurityAuthentication(ctx); chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); chai_1.expect(ctx.getHeaders()).to.deep.equal({}); @@ -35,7 +35,7 @@ describe("Security Authentication", function () { }); it("Cookie API Key", function () { var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "apiKey", "cookie"); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey"); auth.applySecurityAuthentication(ctx); chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); diff --git a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js index ffb7c282e4e4..bca167ad8671 100644 --- a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js +++ b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js @@ -1,11 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ts_petstore_client_1 = require("ts-petstore-client"); -var ts_petstore_client_2 = require("ts-petstore-client"); var chai_1 = require("chai"); var FormData = require("form-data"); var libs = { - "isomorphic-fetch": new ts_petstore_client_2.IsomorphicFetchHttpLibrary() + "isomorphic-fetch": new ts_petstore_client_1.IsomorphicFetchHttpLibrary() }; var _loop_1 = function (libName) { var lib = libs[libName]; diff --git a/samples/client/petstore/typescript/tests/default/dist/test.js b/samples/client/petstore/typescript/tests/default/dist/test.js new file mode 100644 index 000000000000..5ebd748a5a91 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/test.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var MiddlewareA = /** @class */ (function () { + function MiddlewareA() { + } + MiddlewareA.prototype.pre = function (request) { + console.log(request); + return Promise.resolve(request); + }; + MiddlewareA.prototype.post = function (response) { + console.log(response); + return Promise.resolve(response); + }; + return MiddlewareA; +}()); +var config = new ts_petstore_client_1.Configuration({ + middleware: [ + new MiddlewareA() + ] +}); +var api = new ts_petstore_client_1.PetApi(config); +api.getPetById(3).then(function (pet) { + console.log(pet); +}).catch(function (err) { + console.log(err); +}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js new file mode 100644 index 000000000000..e0e55de464a6 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var ts_petstore_client_2 = require("ts-petstore-client"); +var chai_1 = require("chai"); +describe("Security Authentication", function () { + describe("No Authentication", function () { + it("No Authentication", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var noAuth = new ts_petstore_client_1.NoAuthentication(); + noAuth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.deep.equal({}); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + }); + describe("API Key Authentication", function () { + // TODO: make all params const variables + it("Header API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); + chai_1.expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + it("Query API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "query", "apiKey"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); + chai_1.expect(ctx.getHeaders()).to.deep.equal({}); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + it("Cookie API Key", function () { + var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); + var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey"); + auth.applySecurityAuthentication(ctx); + chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); + chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); + chai_1.expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); + chai_1.expect(ctx.getBody()).to.equal(""); + }); + }); +}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js new file mode 100644 index 000000000000..bca167ad8671 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js @@ -0,0 +1,64 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var chai_1 = require("chai"); +var FormData = require("form-data"); +var libs = { + "isomorphic-fetch": new ts_petstore_client_1.IsomorphicFetchHttpLibrary() +}; +var _loop_1 = function (libName) { + var lib = libs[libName]; + describe("Isomorphic Fetch", function () { + it("GET-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/get", ts_petstore_client_1.HttpMethod.GET); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["headers"]).to.exist; + chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + done(); + }).catch(function (e) { + done(e); + }); + }); + it("POST-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/post", ts_petstore_client_1.HttpMethod.POST); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + requestContext.addCookie("test-cookie", "cookie-value"); + var formData = new FormData(); + formData.append("test", "test2"); + formData.append("testFile", Buffer.from("abc"), "fileName.json"); + requestContext.setBody(formData); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["headers"]).to.exist; + chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + chai_1.expect(body["files"]["testFile"]).to.equal("abc"); + chai_1.expect(body["form"]["test"]).to.equal("test2"); + done(); + }).catch(function (e) { + done(e); + }); + }); + it("Cookies-Request", function (done) { + var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/cookies", ts_petstore_client_1.HttpMethod.GET); + requestContext.addCookie("test-cookie", "cookie-value"); + lib.send(requestContext).then(function (resp) { + chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + var body = JSON.parse(resp.body); + chai_1.expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); + done(); + }).catch(function (e) { + done(e); + }); + }); + }); +}; +for (var libName in libs) { + _loop_1(libName); +} diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 2cdcc84cc4aa..b2cd0c08c8f2 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@types/chai": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", - "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", "dev": true }, "@types/form-data": { @@ -19,9 +19,9 @@ }, "dependencies": { "@types/node": { - "version": "10.5.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz", - "integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ==" + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" } } }, @@ -38,9 +38,9 @@ "dev": true }, "@types/node": { - "version": "8.10.25", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.25.tgz", - "integrity": "sha512-WXvAXaknB0c2cJ7N44e1kUrVu5K90mSfPPaT5XxfuSMxEWva86EYIwxUZM3jNZ2P1CIC9e2z4WJqpAF69PQxeA==", + "version": "8.10.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.36.tgz", + "integrity": "sha512-SL6KhfM7PTqiFmbCW3eVNwVBZ+88Mrzbuvn9olPsfv43mbiWaFY+nRcz/TGGku0/lc2FepdMbImdMY1JrQ+zbw==", "dev": true }, "ansi-styles": { @@ -96,17 +96,17 @@ "dev": true }, "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" + "pathval": "^1.1.0", + "type-detect": "^4.0.5" } }, "chalk": { @@ -126,29 +126,29 @@ "dev": true }, "color-convert": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", - "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "requires": { - "color-name": "1.1.1" + "color-name": "1.1.3" } }, "color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { "delayed-stream": "~1.0.0" } }, "commander": { "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, @@ -225,12 +225,12 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, @@ -315,7 +315,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -331,9 +331,9 @@ } }, "make-error": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", - "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==" + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==" }, "memory-fs": { "version": "0.4.1", @@ -346,16 +346,16 @@ } }, "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + "version": "1.36.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" }, "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "requires": { - "mime-db": "~1.35.0" + "mime-db": "~1.36.0" } }, "minimatch": { @@ -369,12 +369,12 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -382,7 +382,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -404,6 +404,17 @@ "minimatch": "3.0.4", "mkdirp": "0.5.1", "supports-color": "5.4.0" + }, + "dependencies": { + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "ms": { @@ -458,7 +469,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -478,9 +489,9 @@ "dev": true }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "source-map": { @@ -516,9 +527,9 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "requires": { "has-flag": "^3.0.0" } @@ -570,10 +581,6 @@ "url-parse": "^1.4.3" }, "dependencies": { - "@types/chai": { - "version": "4.1.4", - "bundled": true - }, "@types/form-data": { "version": "2.2.1", "bundled": true, @@ -585,103 +592,29 @@ "version": "0.0.34", "bundled": true }, - "@types/mocha": { - "version": "5.2.5", - "bundled": true - }, "@types/node": { - "version": "10.5.8", - "bundled": true - }, - "arrify": { - "version": "1.0.1", - "bundled": true - }, - "assertion-error": { - "version": "1.1.0", + "version": "10.12.0", "bundled": true }, "asynckit": { "version": "0.4.0", "bundled": true }, - "balanced-match": { - "version": "1.0.0", - "bundled": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "bundled": true - }, "btoa": { "version": "1.2.1", "bundled": true }, - "buffer-from": { - "version": "1.1.1", - "bundled": true - }, - "chai": { - "version": "4.1.2", - "bundled": true, - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" - } - }, - "check-error": { - "version": "1.0.2", - "bundled": true - }, "combined-stream": { - "version": "1.0.6", + "version": "1.0.7", "bundled": true, "requires": { "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.15.1", - "bundled": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "debug": { - "version": "3.1.0", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-eql": { - "version": "3.0.1", - "bundled": true, - "requires": { - "type-detect": "^4.0.0" - } - }, "delayed-stream": { "version": "1.0.0", "bundled": true }, - "diff": { - "version": "3.5.0", - "bundled": true - }, "encoding": { "version": "0.1.12", "bundled": true, @@ -690,73 +623,25 @@ } }, "es6-promise": { - "version": "4.2.4", - "bundled": true - }, - "escape-string-regexp": { - "version": "1.0.5", + "version": "4.2.5", "bundled": true }, "form-data": { - "version": "2.3.2", + "version": "2.3.3", "bundled": true, "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "get-func-name": { - "version": "2.0.0", - "bundled": true - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "bundled": true - }, - "has-flag": { - "version": "3.0.0", - "bundled": true - }, - "he": { - "version": "1.1.1", - "bundled": true - }, "iconv-lite": { - "version": "0.4.23", + "version": "0.4.24", "bundled": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, "is-stream": { "version": "1.1.0", "bundled": true @@ -769,60 +654,17 @@ "whatwg-fetch": ">=0.10.0" } }, - "make-error": { - "version": "1.3.4", - "bundled": true - }, "mime-db": { - "version": "1.35.0", + "version": "1.36.0", "bundled": true }, "mime-types": { - "version": "2.1.19", + "version": "2.1.20", "bundled": true, "requires": { - "mime-db": "~1.35.0" + "mime-db": "~1.36.0" } }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "bundled": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, "node-fetch": { "version": "1.7.3", "bundled": true, @@ -831,23 +673,8 @@ "is-stream": "^1.0.1" } }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "pathval": { - "version": "1.1.0", - "bundled": true - }, "querystringify": { - "version": "2.0.0", + "version": "2.1.0", "bundled": true }, "requires-port": { @@ -858,49 +685,6 @@ "version": "2.1.2", "bundled": true }, - "source-map": { - "version": "0.6.1", - "bundled": true - }, - "source-map-support": { - "version": "0.5.8", - "bundled": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "supports-color": { - "version": "5.4.0", - "bundled": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "ts-node": { - "version": "7.0.1", - "bundled": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true - } - } - }, - "type-detect": { - "version": "4.0.8", - "bundled": true - }, "typescript": { "version": "2.9.2", "bundled": true @@ -914,15 +698,7 @@ } }, "whatwg-fetch": { - "version": "2.0.4", - "bundled": true - }, - "wrappy": { - "version": "1.0.2", - "bundled": true - }, - "yn": { - "version": "2.0.0", + "version": "3.0.0", "bundled": true } } diff --git a/samples/client/petstore/typescript/builds/default/test.ts b/samples/client/petstore/typescript/tests/default/test.ts similarity index 71% rename from samples/client/petstore/typescript/builds/default/test.ts rename to samples/client/petstore/typescript/tests/default/test.ts index 84720175224b..763d9ea8db0f 100644 --- a/samples/client/petstore/typescript/builds/default/test.ts +++ b/samples/client/petstore/typescript/tests/default/test.ts @@ -1,7 +1,4 @@ -import {PetApi} from './index'; -import {Configuration } from './configuration'; -import { Middleware } from './middleware'; -import { RequestContext, ResponseContext } from './http/http'; +import {PetApi, Configuration, Middleware, RequestContext, ResponseContext} from 'ts-petstore-client'; class MiddlewareA implements Middleware { diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts index c7aa44e6235b..790d34caaa86 100644 --- a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -21,7 +21,7 @@ describe("Security Authentication", () => { // TODO: make all params const variables it("Header API Key", () => { let ctx = new RequestContext("http://google.com", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "header"); + let auth = new APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); @@ -32,7 +32,7 @@ describe("Security Authentication", () => { it("Query API Key", () => { let ctx = new RequestContext("http://google.com?a=b", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "query"); + let auth = new APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.contain("paramName=apiKey"); @@ -42,7 +42,7 @@ describe("Security Authentication", () => { it("Cookie API Key", () => { let ctx = new RequestContext("http://google.com", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "apiKey", "cookie"); + let auth = new APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index f6c6230ff603..181477a408c4 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -1,5 +1,4 @@ -import {RequestContext, HttpMethod, ResponseContext, HttpLibrary} from "ts-petstore-client"; -import {IsomorphicFetchHttpLibrary} from 'ts-petstore-client'; +import {RequestContext, HttpMethod, ResponseContext, HttpLibrary, IsomorphicFetchHttpLibrary } from "ts-petstore-client"; import { expect} from "chai"; import * as FormData from "form-data"; From 3eaa5e54efb514907267614c958ed3c5ce6d180b Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 28 Oct 2018 10:28:17 +0100 Subject: [PATCH 17/85] Removed TODOs --- .../src/main/resources/typescript/api/api.mustache | 1 - .../src/main/resources/typescript/api/middleware.mustache | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 8e88ae4e6910..4a216f08bb9b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -77,7 +77,6 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{^consumes}} requestContext.setHeaderParam("Content-Type", "application/json"); {{/consumes}} - // TODO: deal with this? Could be useful for server definition {{#consumes.0}} requestContext.setHeaderParam("Content-Type", "{{{mediaType}}}"); {{/consumes.0}} diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index 3ac072bab22c..bb2037740f24 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -3,6 +3,4 @@ import {RequestContext, ResponseContext} from './http/http'; export interface Middleware { pre(context: RequestContext): Promise; post(context: ResponseContext): Promise; -} - -// TODO: package.json set npmName \ No newline at end of file +} \ No newline at end of file From 4c11314a7b35bfc8b004da305426a32771a2f0eb Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 28 Oct 2018 10:51:23 +0100 Subject: [PATCH 18/85] Added pom.xml files to TypeScript PetStore client samples --- .../typescript/builds/default/pom.xml | 26 +++++++++++++++++++ .../petstore/typescript/tests/default/pom.xml | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 samples/client/petstore/typescript/builds/default/pom.xml diff --git a/samples/client/petstore/typescript/builds/default/pom.xml b/samples/client/petstore/typescript/builds/default/pom.xml new file mode 100644 index 000000000000..e00676472b41 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + org.openapitools + TypeScriptBuildPestoreClientSample + pom + 1.0-SNAPSHOT + TS Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + + diff --git a/samples/client/petstore/typescript/tests/default/pom.xml b/samples/client/petstore/typescript/tests/default/pom.xml index d9f5844d4fcb..d352f8131e11 100644 --- a/samples/client/petstore/typescript/tests/default/pom.xml +++ b/samples/client/petstore/typescript/tests/default/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.wordnik - TypeScriptClientTest + org.openapitools + TypeScriptPestoreClientTests pom 1.0-SNAPSHOT TS Petstore Test Client From 988df1f7a517b12bbfa185c06767c3782eaf51d0 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 28 Oct 2018 13:51:15 +0100 Subject: [PATCH 19/85] Removed tabs from TypeScriptClientCodegen --- .../codegen/languages/TypeScriptClientCodegen.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index b6ad78e13ef9..db1e781f2c39 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -115,7 +115,7 @@ public TypeScriptClientCodegen() { 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")); // TODO: gen package.json? - + //Files for building our lib supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); @@ -517,8 +517,8 @@ public Map postProcessModels(Map objs) { } } for (Map mo : models) { - CodegenModel cm = (CodegenModel) mo.get("model"); - // Add additional filename information for imports + CodegenModel cm = (CodegenModel) mo.get("model"); + // Add additional filename information for imports mo.put("tsImports", toTsImports(cm, cm.imports)); } return objs; From 0867522b0a7b81dec7889bbaf7928de4201cbe78 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 28 Oct 2018 23:43:33 +0100 Subject: [PATCH 20/85] Added ts client codegen to root pom.xml and travis --- .travis.yml | 1 + pom.xml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3bb3c73cb7f8..42acfee85c41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ cache: - $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor - $HOME/samples/client/petstore/ruby/vendor/bundle - $HOME/samples/client/petstore/python/.venv/ + - $HOME/samples/client/petstore/typescript/tests/default/node_modules - $HOME/samples/client/petstore/typescript-node/npm/node_modules - $HOME/samples/client/petstore/typescript-node/npm/typings/ - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules diff --git a/pom.xml b/pom.xml index b9ff2c632c3d..551b2982e3f9 100644 --- a/pom.xml +++ b/pom.xml @@ -991,6 +991,18 @@ samples/server/petstore/jaxrs-spec-interface-response + + typescript-client-tests-default + + + env + java + + + + samples/client/petstore/typescript/tests/default + + typescript-fetch-client-tests-default @@ -1260,6 +1272,8 @@ samples/client/petstore/python-tornado samples/openapi3/client/petstore/python samples/openapi3/client/petstore/python-experimental + samples/client/petstore/typescript/builds/default + samples/client/petstore/typescript/tests/default samples/client/petstore/typescript-fetch/builds/default samples/client/petstore/typescript-fetch/builds/es6-target samples/client/petstore/typescript-fetch/builds/with-npm-version From 525f48d6942b185a130e0b1d780b2112c7b46eaf Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 2 Dec 2018 19:47:09 +0100 Subject: [PATCH 21/85] Added server variable configuration to ts-refactor --- .../typescript/configuration.mustache | 8 ++-- .../typescript/http/servers.mustache | 41 ++++++++++++++----- .../typescript/builds/default/apis/PetApi.ts | 2 - .../builds/default/apis/StoreApi.ts | 1 - .../typescript/builds/default/apis/UserApi.ts | 4 -- .../builds/default/configuration.ts | 8 ++-- .../typescript/builds/default/middleware.ts | 4 +- .../typescript/builds/default/servers.ts | 35 ++++++++++++---- 8 files changed, 67 insertions(+), 36 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index c672e9a4d00a..41d7a075f517 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,12 +1,12 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; -import {ServerConfiguration, servers} from './servers'; +import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; export interface ConfigurationParameters { - baseServer?: ServerConfiguration; + baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests authMethods?: AuthMethodsConfiguration @@ -14,13 +14,13 @@ export interface ConfigurationParameters { export class Configuration { - baseServer: ServerConfiguration; + baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; authMethods: AuthMethods; constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); diff --git a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache index 6d738c290966..3b7065193228 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache @@ -1,19 +1,38 @@ import {RequestContext, HttpMethod} from './http/http'; -export class ServerConfiguration { +export class ServerConfiguration { - public constructor(private url: string) { + public constructor(private url: string, private variableConfiguration: T) { } - + + public setVariables(variableConfiguration: Partial) { + for (const key in variableConfiguration) { + const val = variableConfiguration[key] + // We know that val isn't undefined here - hopefully + if (val !== undefined) { + this.variableConfiguration[key] = val as T[Extract]; + } + } + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + } + return replacedUrl + } + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { - return new RequestContext(this.url + endpoint, httpMethod); + return new RequestContext(this.getUrl() + endpoint, httpMethod); } } -{{#openAPI}} -export const servers = [ - {{#servers}} - new ServerConfiguration("{{url}}"){{^last}},{{/last}} - {{/servers}} -] -{{/openAPI}} \ No newline at end of file +{{#servers}} +export const server{{-index}} = new ServerConfiguration<{ {{#variables}} "{{name}}": {{#enumValues}}"{{.}}"{{^-last}} | {{/-last}}{{/enumValues}}{{^enumValues}}string{{/enumValues}}{{^-last}},{{/-last}} {{/variables}} }>("{{url}}", { {{#variables}} "{{name}}": "{{defaultValue}}" {{^-last}},{{/-last}}{{/variables}} }) +{{/servers}} diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 75deb2c89f12..049a3a820ddb 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -30,7 +30,6 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - // TODO: deal with this? Could be useful for server definition requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; @@ -205,7 +204,6 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - // TODO: deal with this? Could be useful for server definition requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 3445cbf2ebfe..41ca20d0b2a2 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -113,7 +113,6 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: deal with this? Could be useful for server definition // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; const serializedBody = needsSerialization ? JSON.stringify(order || {}) : (order.toString() || ""); // TODO: `toString` call is unnecessary diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index ebb1c357f1d0..428bcd845b18 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -30,7 +30,6 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: deal with this? Could be useful for server definition // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary @@ -63,7 +62,6 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: deal with this? Could be useful for server definition // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary @@ -96,7 +94,6 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: deal with this? Could be useful for server definition // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary @@ -251,7 +248,6 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: deal with this? Could be useful for server definition // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index c672e9a4d00a..41d7a075f517 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -1,12 +1,12 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; -import {ServerConfiguration, servers} from './servers'; +import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; export interface ConfigurationParameters { - baseServer?: ServerConfiguration; + baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests authMethods?: AuthMethodsConfiguration @@ -14,13 +14,13 @@ export interface ConfigurationParameters { export class Configuration { - baseServer: ServerConfiguration; + baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; authMethods: AuthMethods; constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index 3ac072bab22c..bb2037740f24 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -3,6 +3,4 @@ import {RequestContext, ResponseContext} from './http/http'; export interface Middleware { pre(context: RequestContext): Promise; post(context: ResponseContext): Promise; -} - -// TODO: package.json set npmName \ No newline at end of file +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts index 7cc55b40db0c..85aeaa2c8a86 100644 --- a/samples/client/petstore/typescript/builds/default/servers.ts +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -1,15 +1,36 @@ import {RequestContext, HttpMethod} from './http/http'; -export class ServerConfiguration { +export class ServerConfiguration { - public constructor(private url: string) { + public constructor(private url: string, private variableConfiguration: T) { } - + + public setVariables(variableConfiguration: Partial) { + for (const key in variableConfiguration) { + const val = variableConfiguration[key] + // We know that val isn't undefined here - hopefully + if (val !== undefined) { + this.variableConfiguration[key] = val as T[Extract]; + } + } + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + } + return replacedUrl + } + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { - return new RequestContext(this.url + endpoint, httpMethod); + return new RequestContext(this.getUrl() + endpoint, httpMethod); } } -export const servers = [ - new ServerConfiguration("http://petstore.swagger.io/v2"), -] +export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) From c2b7422a819c2fdad37d3e45fac4b8be04799a05 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 2 Dec 2018 20:34:25 +0100 Subject: [PATCH 22/85] [TS-Refactor] Added tests for Object Serializer --- .../tests/default/package-lock.json | 777 +++++++++++++++++- .../typescript/tests/default/package.json | 6 +- .../test/models/ObjectSerializer.test.ts | 223 +++++ .../typescript/tests/default/tsconfig.json | 3 +- 4 files changed, 965 insertions(+), 44 deletions(-) create mode 100644 samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index b2cd0c08c8f2..8c91101d4447 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -38,11 +38,62 @@ "dev": true }, "@types/node": { - "version": "8.10.36", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.36.tgz", - "integrity": "sha512-SL6KhfM7PTqiFmbCW3eVNwVBZ+88Mrzbuvn9olPsfv43mbiWaFY+nRcz/TGGku0/lc2FepdMbImdMY1JrQ+zbw==", + "version": "8.10.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", + "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", "dev": true }, + "@types/rewire": { + "version": "2.5.28", + "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", + "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" + }, + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" + } + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" + }, + "ansi-escapes": { + "version": "3.1.0", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -51,6 +102,14 @@ "color-convert": "^1.9.0" } }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -67,11 +126,52 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "big.js": { "version": "3.2.0", @@ -83,7 +183,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -95,6 +194,24 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "requires": { + "callsites": "^0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" + }, "chai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", @@ -119,12 +236,40 @@ "supports-color": "^5.3.0" } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==" + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -155,20 +300,38 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, "requires": { "ms": "2.0.0" } @@ -182,6 +345,11 @@ "type-detect": "^4.0.0" } }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -192,6 +360,14 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "requires": { + "esutils": "^2.0.2" + } + }, "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", @@ -224,6 +400,158 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "eslint": { + "version": "4.19.1", + "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "requires": { + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", + "table": "4.0.2", + "text-table": "~0.2.0" + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" + }, + "espree": { + "version": "3.5.4", + "resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "external-editor": { + "version": "2.2.0", + "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "requires": { + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", + "write": "^0.2.1" + } + }, "form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", @@ -237,8 +565,12 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, "get-func-name": { "version": "2.0.0", @@ -250,7 +582,6 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -260,11 +591,15 @@ "path-is-absolute": "^1.0.0" } }, + "globals": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", + "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==" + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, "growl": { "version": "1.10.5", @@ -272,6 +607,14 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -291,11 +634,28 @@ "parse-passwd": "^1.0.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -304,14 +664,77 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==" }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" }, "json5": { "version": "0.5.1", @@ -319,6 +742,15 @@ "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "loader-utils": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", @@ -330,6 +762,20 @@ "json5": "^0.5.0" } }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, "make-error": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", @@ -358,11 +804,15 @@ "mime-db": "~1.36.0" } }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -420,24 +870,57 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -446,8 +929,12 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" }, "pathval": { "version": "1.1.0", @@ -455,11 +942,25 @@ "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", + "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==" }, "prr": { "version": "1.0.1", @@ -467,11 +968,15 @@ "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", "dev": true }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, "readable-stream": { "version": "2.3.6", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -482,17 +987,111 @@ "util-deprecate": "~1.0.1" } }, + "regexpp": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=" + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "rewire": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/rewire/-/rewire-4.0.1.tgz", + "integrity": "sha512-+7RQ/BYwTieHVXetpKhT11UbfF6v1kGhKFrtZN7UDL2PybMsSt/rpLWeEUGF5Ndsl1D5BxiCB14VDJyoX+noYw==", + "requires": { + "eslint": "^4.19.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "requires": { + "is-promise": "^2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=" + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "requires": { + "rx-lite": "*" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } }, "source-map": { "version": "0.5.7", @@ -507,15 +1106,43 @@ "source-map": "^0.5.6" } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "requires": { "safe-buffer": "~5.1.0" } }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + } + } + }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -534,12 +1161,43 @@ "has-flag": "^3.0.0" } }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "requires": { + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + }, "tapable": { "version": "0.2.8", "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", "dev": true }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "requires": { + "os-tmpdir": "~1.0.2" + } + }, "ts-loader": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.7.tgz", @@ -712,12 +1370,25 @@ "strip-json-comments": "^2.0.0" } }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", @@ -727,8 +1398,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "v8flags": { "version": "3.1.1", @@ -738,11 +1408,36 @@ "homedir-polyfill": "^1.0.1" } }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "requires": { + "mkdirp": "^0.5.1" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" }, "yn": { "version": "2.0.0", diff --git a/samples/client/petstore/typescript/tests/default/package.json b/samples/client/petstore/typescript/tests/default/package.json index 32c3c525b210..1f924a40bf3b 100644 --- a/samples/client/petstore/typescript/tests/default/package.json +++ b/samples/client/petstore/typescript/tests/default/package.json @@ -2,7 +2,9 @@ "private": true, "dependencies": { "@types/form-data": "^2.2.1", + "@types/rewire": "^2.5.28", "form-data": "^2.3.2", + "rewire": "^4.0.1", "ts-node": "^3.3.0", "ts-petstore-client": "file:../../builds/default" }, @@ -13,10 +15,10 @@ }, "devDependencies": { "@types/chai": "^4.0.1", - "chai": "^4.1.0", "@types/isomorphic-fetch": "0.0.34", "@types/mocha": "^2.2.41", - "@types/node": "^8.0.14", + "@types/node": "^8.10.38", + "chai": "^4.1.0", "mocha": "^5.2.0", "ts-loader": "^2.3.0", "typescript": "^2.4.1" diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts new file mode 100644 index 000000000000..5ba6e3f94422 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -0,0 +1,223 @@ +const rewire = require("rewire") +import { expect} from "chai"; +import {Pet, Category, Tag} from "ts-petstore-client" + + +const objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js") + +const ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer") +//console.log(ObjectSerializer) + + +describe("ObjectSerializer", () => { + describe("Serialize", () => { + it("String", () => { + const input = "test string" + expect(ObjectSerializer.serialize(input, "string")).to.equal("test string") + }); + + it("Number", () => { + const input = 1337 + expect(ObjectSerializer.serialize(input, "number")).to.equal(1337) + }); + + it("String Array", () => { + const input = ["a", "b", "c"] + expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal(["a", "b", "c"]) + }) + + it("Number Array", () => { + const input = [ 1337, 42, 0] + expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal([1337, 42, 0]) + }) + + it("Date", () => { + const input = new Date(1543777609696) + expect(ObjectSerializer.serialize(input, "Date")).to.equal(input.toISOString()) + }) + + it("Object", () => { + const input = {"a": "test", "b": { "test": 5}} + expect(ObjectSerializer.serialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5}}) + }) + + it("Class", () => { + const input = new Category() + input.id = 4 + input.name = "Test" + expect(ObjectSerializer.serialize(input, "Category")).to.deep.equal({ "id": input.id, "name": input.name}) + }); + + it ("Enum", () => { + const input = Pet.StatusEnum.Available + expect(ObjectSerializer.serialize(input, "Pet.StatusEnum")).to.equal("available") + }) + + it("Complex Class", () => { + const tags = [] + const tagResult = [] + for (let i = 0; i < 2; i++) { + const tag = new Tag() + tag.id = i + tag.name = "Tag" + i + tags.push(tag) + tagResult.push({ + "id": tag.id, + "name": tag.name + }) + } + + const category = new Category() + category.id = 4 + category.name = "TestCat" + const pet = new Pet() + pet.id = 145 + pet.category = category + pet.name = "PetName" + pet.photoUrls = [ "url", "other url"] + pet.status = Pet.StatusEnum.Available + pet.tags = tags + + expect(ObjectSerializer.serialize(pet, "Pet")).to.deep.equal({ + "id": pet.id, + "name": pet.name, + "category": { + "id": category.id, + "name": category.name + }, + "photoUrls": [ "url", "other url"], + "status": "available", + "tags": tagResult + }) + }) + it("Array of Class", () => { + const categories = [] + const result = [] + for (let i = 0; i < 2; i++) { + const category = new Category() + category.id = i + category.name = "Cat" + i + categories.push(category) + result.push({ + "id": category.id, + "name": category.name + }) + } + + expect(ObjectSerializer.serialize(categories, "Array")).to.deep.equal(result) + }) + }) + + describe("Deserialize", () => { + it("String", () => { + const input = "test string" + expect(ObjectSerializer.deserialize(input, "string")).to.equal("test string") + }); + + it("Number", () => { + const input = 1337 + expect(ObjectSerializer.deserialize(input, "number")).to.equal(1337) + }); + + it("String Array", () => { + const input = ["a", "b", "c"] + expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal(["a", "b", "c"]) + }) + + it("Number Array", () => { + const input = [ 1337, 42, 0] + expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal([1337, 42, 0]) + }) + + it("Date", () => { + const input = new Date(1543777609696) + expect(ObjectSerializer.deserialize(input.toISOString(), "Date").getTime()).to.equal(input.getTime()) + }) + + it("Object", () => { + const input = {"a": "test", "b": { "test": 5}} + expect(ObjectSerializer.deserialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5}}) + }) + + it("Class", () => { + const input = new Category() + input.id = 4 + input.name = "Test" + const deserialized = ObjectSerializer.deserialize({ "id": 4, "name": "Test"}, "Category") + + expect(deserialized.constructor.name).to.equal("Category") + expect(deserialized).to.deep.equal(input) + }); + + it ("Enum", () => { + const input = Pet.StatusEnum.Available + expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum")).to.equal(input) + }) + + it("Complex Class", () => { + const tags = [] + const tagResult = [] + for (let i = 0; i < 2; i++) { + const tag = new Tag() + tag.id = i + tag.name = "Tag" + i + tags.push(tag) + tagResult.push({ + "id": tag.id, + "name": tag.name + }) + } + + const category = new Category() + category.id = 4 + category.name = "TestCat" + const pet = new Pet() + pet.id = 145 + pet.category = category + pet.name = "PetName" + pet.photoUrls = [ "url", "other url"] + pet.status = Pet.StatusEnum.Available + pet.tags = tags + + const deserialized = ObjectSerializer.deserialize({ + "id": pet.id, + "name": pet.name, + "category": { + "id": category.id, + "name": category.name + }, + "photoUrls": [ "url", "other url"], + "status": "available", + "tags": tagResult + }, "Pet") as Pet + + expect(deserialized.constructor.name).to.equal("Pet") + expect(deserialized.category.constructor.name).to.equal("Category") + for (let i = 0; i < deserialized.tags.length; i++){ + expect(deserialized.tags[i].constructor.name).to.equal("Tag") + } + expect(deserialized).to.deep.equal(pet) + }) + + it("Array of Class", () => { + const categories = [] + const result = [] + for (let i = 0; i < 2; i++) { + const category = new Category() + category.id = i + category.name = "Cat" + i + categories.push(category) + result.push({ + "id": category.id, + "name": category.name + }) + } + + const deserialized = ObjectSerializer.deserialize(result, "Array") + for (let i = 0; i < categories.length; i++) { + expect(deserialized[i].constructor.name).to.equal("Category") + } + expect(deserialized).to.deep.equal(categories) + }) + }) +}) diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/client/petstore/typescript/tests/default/tsconfig.json index 6524f781742b..3470aabd0c3c 100644 --- a/samples/client/petstore/typescript/tests/default/tsconfig.json +++ b/samples/client/petstore/typescript/tests/default/tsconfig.json @@ -6,7 +6,8 @@ "sourceMap": false, "outDir": "dist", "types": [ - "mocha" + "mocha", + "node" ], "lib": [ "es6", From e41df36261628c360617d275bb98be5a477b1879 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 2 Dec 2018 21:01:03 +0100 Subject: [PATCH 23/85] Added simple test for PetApi --- .../languages/TypeScriptClientCodegen.java | 3 +- .../typescript/generators/PromiseAPI.mustache | 2 +- .../{api => model}/ObjectSerializer.mustache | 0 .../typescript/builds/default/PromiseAPI.ts | 40 ++-- .../default/dist/test/api/PetApi.test.js | 25 +++ .../dist/test/models/ObjectSerializer.test.js | 193 ++++++++++++++++++ .../tests/default/test/api/PetApi.test.ts | 26 +++ .../test/models/ObjectSerializer.test.ts | 1 - 8 files changed, 267 insertions(+), 23 deletions(-) rename modules/openapi-generator/src/main/resources/typescript/{api => model}/ObjectSerializer.mustache (100%) create mode 100644 samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js create mode 100644 samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js create mode 100644 samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index db1e781f2c39..736245f38945 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -130,6 +130,7 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); supportingFiles.add(new SupportingFile("model/models_all.mustache", "models", "all.ts")); + // TODO: add supporting files depending on cli parameter e.g. fetch vs angular supportingFiles.add(new SupportingFile("generators/PromiseAPI.mustache", "PromiseAPI.ts")); supportingFiles.add(new SupportingFile("generators/fetch/index.mustache", "index.ts")); @@ -137,7 +138,7 @@ public TypeScriptClientCodegen() { // models // TODO: properly set model and api packages this.setModelPackage(""); - supportingFiles.add(new SupportingFile("api/ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); + supportingFiles.add(new SupportingFile("model/ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); modelTemplateFiles.put("model/model.mustache", ".ts"); // api diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache index 5198b5d89c6f..4922915ba5c9 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache @@ -26,7 +26,7 @@ export class {{classname}} { const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } diff --git a/modules/openapi-generator/src/main/resources/typescript/api/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/api/ObjectSerializer.mustache rename to modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache diff --git a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts index ffce3d9bf4ed..d6888f214b54 100644 --- a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts @@ -23,7 +23,7 @@ export class PetApi { const requestContext = this.requestFactory.addPet(pet, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -42,7 +42,7 @@ export class PetApi { const requestContext = this.requestFactory.deletePet(petId, apiKey, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -61,7 +61,7 @@ export class PetApi { const requestContext = this.requestFactory.findPetsByStatus(status, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -80,7 +80,7 @@ export class PetApi { const requestContext = this.requestFactory.findPetsByTags(tags, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -99,7 +99,7 @@ export class PetApi { const requestContext = this.requestFactory.getPetById(petId, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -118,7 +118,7 @@ export class PetApi { const requestContext = this.requestFactory.updatePet(pet, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -137,7 +137,7 @@ export class PetApi { const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -156,7 +156,7 @@ export class PetApi { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -191,7 +191,7 @@ export class StoreApi { const requestContext = this.requestFactory.deleteOrder(orderId, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -210,7 +210,7 @@ export class StoreApi { const requestContext = this.requestFactory.getInventory(options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -229,7 +229,7 @@ export class StoreApi { const requestContext = this.requestFactory.getOrderById(orderId, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -248,7 +248,7 @@ export class StoreApi { const requestContext = this.requestFactory.placeOrder(order, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -283,7 +283,7 @@ export class UserApi { const requestContext = this.requestFactory.createUser(user, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -302,7 +302,7 @@ export class UserApi { const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -321,7 +321,7 @@ export class UserApi { const requestContext = this.requestFactory.createUsersWithListInput(user, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -340,7 +340,7 @@ export class UserApi { const requestContext = this.requestFactory.deleteUser(username, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -359,7 +359,7 @@ export class UserApi { const requestContext = this.requestFactory.getUserByName(username, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -378,7 +378,7 @@ export class UserApi { const requestContext = this.requestFactory.loginUser(username, password, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -397,7 +397,7 @@ export class UserApi { const requestContext = this.requestFactory.logoutUser(options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } @@ -416,7 +416,7 @@ export class UserApi { const requestContext = this.requestFactory.updateUser(username, user, options); // build promise chain - let middlewarePrePromise =Promise.resolve(requestContext); + let middlewarePrePromise = Promise.resolve(requestContext); for (let middleware of this.configuration.middleware) { middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); } diff --git a/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js b/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js new file mode 100644 index 000000000000..41e07205f980 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ts_petstore_client_1 = require("ts-petstore-client"); +var chai_1 = require("chai"); +var configuration = new ts_petstore_client_1.Configuration(); +var petApi = new ts_petstore_client_1.PetApi(configuration); +describe("PetApi", function () { + it("addPet", function (done) { + var pet = new ts_petstore_client_1.Pet(); + pet.id = Math.floor(Math.random() * 100000); + pet.name = "PetName"; + pet.photoUrls = []; + pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; + pet.tags = []; + pet.category = undefined; + petApi.addPet(pet).then(function () { + return petApi.getPetById(pet.id); + }).then(function (createdPet) { + chai_1.expect(createdPet).to.deep.equal(pet); + done(); + }).catch(function (err) { + done(err); + }); + }); +}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js new file mode 100644 index 000000000000..94eeb6bb207c --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js @@ -0,0 +1,193 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var rewire = require("rewire"); +var chai_1 = require("chai"); +var ts_petstore_client_1 = require("ts-petstore-client"); +var objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js"); +var ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer"); +describe("ObjectSerializer", function () { + describe("Serialize", function () { + it("String", function () { + var input = "test string"; + chai_1.expect(ObjectSerializer.serialize(input, "string")).to.equal("test string"); + }); + it("Number", function () { + var input = 1337; + chai_1.expect(ObjectSerializer.serialize(input, "number")).to.equal(1337); + }); + it("String Array", function () { + var input = ["a", "b", "c"]; + chai_1.expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal(["a", "b", "c"]); + }); + it("Number Array", function () { + var input = [1337, 42, 0]; + chai_1.expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal([1337, 42, 0]); + }); + it("Date", function () { + var input = new Date(1543777609696); + chai_1.expect(ObjectSerializer.serialize(input, "Date")).to.equal(input.toISOString()); + }); + it("Object", function () { + var input = { "a": "test", "b": { "test": 5 } }; + chai_1.expect(ObjectSerializer.serialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5 } }); + }); + it("Class", function () { + var input = new ts_petstore_client_1.Category(); + input.id = 4; + input.name = "Test"; + chai_1.expect(ObjectSerializer.serialize(input, "Category")).to.deep.equal({ "id": input.id, "name": input.name }); + }); + it("Enum", function () { + var input = ts_petstore_client_1.Pet.StatusEnum.Available; + chai_1.expect(ObjectSerializer.serialize(input, "Pet.StatusEnum")).to.equal("available"); + }); + it("Complex Class", function () { + var tags = []; + var tagResult = []; + for (var i = 0; i < 2; i++) { + var tag = new ts_petstore_client_1.Tag(); + tag.id = i; + tag.name = "Tag" + i; + tags.push(tag); + tagResult.push({ + "id": tag.id, + "name": tag.name + }); + } + var category = new ts_petstore_client_1.Category(); + category.id = 4; + category.name = "TestCat"; + var pet = new ts_petstore_client_1.Pet(); + pet.id = 145; + pet.category = category; + pet.name = "PetName"; + pet.photoUrls = ["url", "other url"]; + pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; + pet.tags = tags; + chai_1.expect(ObjectSerializer.serialize(pet, "Pet")).to.deep.equal({ + "id": pet.id, + "name": pet.name, + "category": { + "id": category.id, + "name": category.name + }, + "photoUrls": ["url", "other url"], + "status": "available", + "tags": tagResult + }); + }); + it("Array of Class", function () { + var categories = []; + var result = []; + for (var i = 0; i < 2; i++) { + var category = new ts_petstore_client_1.Category(); + category.id = i; + category.name = "Cat" + i; + categories.push(category); + result.push({ + "id": category.id, + "name": category.name + }); + } + chai_1.expect(ObjectSerializer.serialize(categories, "Array")).to.deep.equal(result); + }); + }); + describe("Deserialize", function () { + it("String", function () { + var input = "test string"; + chai_1.expect(ObjectSerializer.deserialize(input, "string")).to.equal("test string"); + }); + it("Number", function () { + var input = 1337; + chai_1.expect(ObjectSerializer.deserialize(input, "number")).to.equal(1337); + }); + it("String Array", function () { + var input = ["a", "b", "c"]; + chai_1.expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal(["a", "b", "c"]); + }); + it("Number Array", function () { + var input = [1337, 42, 0]; + chai_1.expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal([1337, 42, 0]); + }); + it("Date", function () { + var input = new Date(1543777609696); + chai_1.expect(ObjectSerializer.deserialize(input.toISOString(), "Date").getTime()).to.equal(input.getTime()); + }); + it("Object", function () { + var input = { "a": "test", "b": { "test": 5 } }; + chai_1.expect(ObjectSerializer.deserialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5 } }); + }); + it("Class", function () { + var input = new ts_petstore_client_1.Category(); + input.id = 4; + input.name = "Test"; + var deserialized = ObjectSerializer.deserialize({ "id": 4, "name": "Test" }, "Category"); + chai_1.expect(deserialized.constructor.name).to.equal("Category"); + chai_1.expect(deserialized).to.deep.equal(input); + }); + it("Enum", function () { + var input = ts_petstore_client_1.Pet.StatusEnum.Available; + chai_1.expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum")).to.equal(input); + }); + it("Complex Class", function () { + var tags = []; + var tagResult = []; + for (var i = 0; i < 2; i++) { + var tag = new ts_petstore_client_1.Tag(); + tag.id = i; + tag.name = "Tag" + i; + tags.push(tag); + tagResult.push({ + "id": tag.id, + "name": tag.name + }); + } + var category = new ts_petstore_client_1.Category(); + category.id = 4; + category.name = "TestCat"; + var pet = new ts_petstore_client_1.Pet(); + pet.id = 145; + pet.category = category; + pet.name = "PetName"; + pet.photoUrls = ["url", "other url"]; + pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; + pet.tags = tags; + var deserialized = ObjectSerializer.deserialize({ + "id": pet.id, + "name": pet.name, + "category": { + "id": category.id, + "name": category.name + }, + "photoUrls": ["url", "other url"], + "status": "available", + "tags": tagResult + }, "Pet"); + chai_1.expect(deserialized.constructor.name).to.equal("Pet"); + chai_1.expect(deserialized.category.constructor.name).to.equal("Category"); + for (var i = 0; i < deserialized.tags.length; i++) { + chai_1.expect(deserialized.tags[i].constructor.name).to.equal("Tag"); + } + chai_1.expect(deserialized).to.deep.equal(pet); + }); + it("Array of Class", function () { + var categories = []; + var result = []; + for (var i = 0; i < 2; i++) { + var category = new ts_petstore_client_1.Category(); + category.id = i; + category.name = "Cat" + i; + categories.push(category); + result.push({ + "id": category.id, + "name": category.name + }); + } + var deserialized = ObjectSerializer.deserialize(result, "Array"); + for (var i = 0; i < categories.length; i++) { + chai_1.expect(deserialized[i].constructor.name).to.equal("Category"); + } + chai_1.expect(deserialized).to.deep.equal(categories); + }); + }); +}); diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts new file mode 100644 index 000000000000..d243f18abf15 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -0,0 +1,26 @@ +import {PetApi, Configuration, Pet} from 'ts-petstore-client' +import { expect, assert } from "chai"; + +const configuration = new Configuration() +const petApi = new PetApi(configuration) + +describe("PetApi", () =>{ + it("addPet", (done) => { + const pet = new Pet() + pet.id = Math.floor(Math.random() * 100000) + pet.name = "PetName" + pet.photoUrls = [] + pet.status = Pet.StatusEnum.Available + pet.tags = [] + pet.category = undefined + + petApi.addPet(pet).then(() => { + return petApi.getPetById(pet.id) + }).then((createdPet) => { + expect(createdPet).to.deep.equal(pet); + done() + }).catch((err) => { + done(err) + }) + }) +}) \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index 5ba6e3f94422..914f6fdea287 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -6,7 +6,6 @@ import {Pet, Category, Tag} from "ts-petstore-client" const objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js") const ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer") -//console.log(ObjectSerializer) describe("ObjectSerializer", () => { From 9b0bb9a399b6891b5162e6e92e70723d8e3c60f7 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 3 Dec 2018 08:46:48 +0100 Subject: [PATCH 24/85] Fixed ObjectSerializer test --- .../typescript/tests/default/.gitignore | 1 + .../tests/default/dist/auth/auth.test.js | 46 ------------- .../dist/http/isomorphic-fetch.test.js | 64 ------------------- .../dist/test/models/ObjectSerializer.test.js | 2 +- .../test/models/ObjectSerializer.test.ts | 2 +- 5 files changed, 3 insertions(+), 112 deletions(-) create mode 100644 samples/client/petstore/typescript/tests/default/.gitignore delete mode 100644 samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js delete mode 100644 samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js diff --git a/samples/client/petstore/typescript/tests/default/.gitignore b/samples/client/petstore/typescript/tests/default/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js deleted file mode 100644 index e0e55de464a6..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var ts_petstore_client_2 = require("ts-petstore-client"); -var chai_1 = require("chai"); -describe("Security Authentication", function () { - describe("No Authentication", function () { - it("No Authentication", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var noAuth = new ts_petstore_client_1.NoAuthentication(); - noAuth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); - describe("API Key Authentication", function () { - // TODO: make all params const variables - it("Header API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); - chai_1.expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Query API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "query", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Cookie API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); - chai_1.expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); -}); diff --git a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js deleted file mode 100644 index bca167ad8671..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var chai_1 = require("chai"); -var FormData = require("form-data"); -var libs = { - "isomorphic-fetch": new ts_petstore_client_1.IsomorphicFetchHttpLibrary() -}; -var _loop_1 = function (libName) { - var lib = libs[libName]; - describe("Isomorphic Fetch", function () { - it("GET-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/get", ts_petstore_client_1.HttpMethod.GET); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("POST-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/post", ts_petstore_client_1.HttpMethod.POST); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - var formData = new FormData(); - formData.append("test", "test2"); - formData.append("testFile", Buffer.from("abc"), "fileName.json"); - requestContext.setBody(formData); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - chai_1.expect(body["files"]["testFile"]).to.equal("abc"); - chai_1.expect(body["form"]["test"]).to.equal("test2"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("Cookies-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/cookies", ts_petstore_client_1.HttpMethod.GET); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); - done(); - }).catch(function (e) { - done(e); - }); - }); - }); -}; -for (var libName in libs) { - _loop_1(libName); -} diff --git a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js index 94eeb6bb207c..0a7f6547ffd7 100644 --- a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js +++ b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var rewire = require("rewire"); var chai_1 = require("chai"); var ts_petstore_client_1 = require("ts-petstore-client"); -var objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js"); +var objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts"); var ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer"); describe("ObjectSerializer", function () { describe("Serialize", function () { diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index 914f6fdea287..342ea63b26c7 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -3,7 +3,7 @@ import { expect} from "chai"; import {Pet, Category, Tag} from "ts-petstore-client" -const objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js") +const objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts") const ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer") From 35b98cf2bca0f0dc7066899ff03281f713a9d45d Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 6 Dec 2018 23:06:17 +0100 Subject: [PATCH 25/85] Added handling for different http status codes and test for deletePet --- .../openapitools/codegen/CodegenResponse.java | 1 + .../openapitools/codegen/DefaultCodegen.java | 1 + .../languages/TypeScriptClientCodegen.java | 46 ++++- .../resources/typescript/api/api.mustache | 55 +++-- .../typescript/api/exception.mustache | 5 + .../generators/fetch/index.mustache | 1 + .../main/resources/typescript/util.mustache | 20 ++ .../typescript/builds/default/apis/PetApi.ts | 185 +++++++++++------ .../builds/default/apis/StoreApi.ts | 104 ++++++---- .../typescript/builds/default/apis/UserApi.ts | 168 +++++++++------ .../builds/default/apis/exception.ts | 5 + .../typescript/builds/default/index.ts | 1 + .../typescript/builds/default/util.ts | 20 ++ .../typescript/tests/default/dist/test.js | 27 --- .../default/dist/test/api/PetApi.test.js | 25 --- .../tests/default/dist/test/auth/auth.test.js | 46 ----- .../dist/test/http/isomorphic-fetch.test.js | 64 ------ .../dist/test/models/ObjectSerializer.test.js | 193 ------------------ .../tests/default/test/api/PetApi.test.ts | 34 ++- .../typescript/tests/default/tsconfig.json | 2 +- 20 files changed, 452 insertions(+), 551 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/api/exception.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/util.mustache create mode 100644 samples/client/petstore/typescript/builds/default/apis/exception.ts create mode 100644 samples/client/petstore/typescript/builds/default/util.ts delete mode 100644 samples/client/petstore/typescript/tests/default/dist/test.js delete mode 100644 samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js delete mode 100644 samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js delete mode 100644 samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js delete mode 100644 samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java index 1edad97316f6..5d618422416a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java @@ -28,6 +28,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { public boolean is4xx; public boolean is5xx; public String message; + public boolean isSuccessCode; public boolean hasMore; public List> examples; public String dataType; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 82cebbf02245..14be4a366233 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3686,6 +3686,7 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { default: throw new RuntimeException("Invalid response code " + responseCode); } + r.isSuccessCode = r.code.startsWith("2"); } Schema responseSchema; if (this.openAPI != null && this.openAPI.getComponents() != null) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 736245f38945..70d65171e1a8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -121,6 +121,9 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); + // Util + supportingFiles.add(new SupportingFile("util.mustache", "", "util.ts")); + supportingFiles.add(new SupportingFile("api/exception.mustache", "apis", "exception.ts")); // http supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts")); @@ -155,9 +158,7 @@ public CodegenType getTag() { } @Override - public Map postProcessOperations(Map operations) { - Map objs = (Map) operations.get("operations"); - + public Map postProcessOperations(Map operations) { // Add additional filename information for model imports in the apis List> imports = (List>) operations.get("imports"); @@ -165,9 +166,48 @@ public Map postProcessOperations(Map operations) im.put("filename", ((String) im.get("import")).replace('.', '/')); im.put("classname", getModelnameFromModelFilename(im.get("import").toString())); } + + @SuppressWarnings("unchecked") + Map operationsMap = (Map) operations.get("operations"); + List operationList = (List) operationsMap.get("operation"); + for (CodegenOperation operation: operationList) { + List responses = operation.responses; + operation.returnType = this.getReturnType(responses); + } return operations; } + private String getReturnType(List responses) { + StringBuilder returnType = new StringBuilder(); + boolean firstReturnType = true; + boolean atLeastOneSuccess = false; + boolean addVoid = false; + System.out.println(responses); + for (CodegenResponse response: responses) { + // TODO: we should probably catch an exception here + if (response.isSuccessCode) { + if (response.dataType != null) { + if (!firstReturnType) { + returnType.append(" | "); + } + returnType.append(response.dataType); + firstReturnType = false; + atLeastOneSuccess = true; + } else { + addVoid = true; + } + } + } + if (!atLeastOneSuccess) { + return null; + } else if (addVoid) { + returnType.append(" | void"); + } + + System.out.println("Return Type: " + returnType); + return returnType.toString(); + } + private String getModelnameFromModelFilename(String filename) { String name = filename.substring((modelPackage() + File.separator).length()); return camelize(name); diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 4a216f08bb9b..218b0636e71f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -3,6 +3,9 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + {{#imports}} import { {{classname}} } from '..{{filename}}'; {{/imports}} @@ -114,26 +117,44 @@ export class {{classname}}ResponseProcessor { {{#operation}} /** * - * @throws {{{returnType}}} if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - {{#returnType}} - const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}") as {{{returnType}}}; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { + {{#responses}} + if (isCodeInRange("{{code}}", response.httpStatusCode)) { + {{#dataType}} + const jsonBody = JSON.parse(response.body); + const body: {{{dataType}}} = ObjectSerializer.deserialize(jsonBody, "{{{dataType}}}") as {{{dataType}}}; + {{#isSuccessCode}} + return body; + {{/isSuccessCode}} + {{^isSuccessCode}} + throw new ApiException<{{{dataType}}}>({{code}}, body); + {{/isSuccessCode}} + {{/dataType}} + {{^dataType}} + {{#isSuccessCode}} + return; + {{/isSuccessCode}} + {{^isSuccessCode}} + throw new ApiException(response.httpStatusCode, "{{message}}"); + {{/isSuccessCode}} + {{/dataType}} } - {{/returnType}} - {{^returnType}} - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + {{/responses}} + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + {{#returnType}} + const jsonBody = JSON.parse(response.body); + const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}") as {{{returnType}}}; + return body; + {{/returnType}} + {{^returnType}} + return; + {{/returnType}} } - {{/returnType}} + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache new file mode 100644 index 000000000000..327ac516a314 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache @@ -0,0 +1,5 @@ +export class ApiException extends Error { + public constructor(public code: number, public body: T) { + super("Got HTTP Status Code " + code) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache index 2bcea78b8ca8..e7c7bd4e5a96 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache @@ -5,3 +5,4 @@ export * from './middleware'; export * from './models/all'; export { Configuration} from './configuration' export * from './PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/util.mustache b/modules/openapi-generator/src/main/resources/typescript/util.mustache new file mode 100644 index 000000000000..af9085e7cbff --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/util.mustache @@ -0,0 +1,20 @@ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 049a3a820ddb..a417d3b75c2e 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -3,6 +3,9 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; @@ -316,118 +319,164 @@ export class PetApiResponseProcessor { /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public addPet(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public addPet(response: ResponseContext): void { + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public deletePet(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public deletePet(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid pet value"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws Array if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByStatus(response: ResponseContext): Array { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public findPetsByStatus(response: ResponseContext): Array { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid status value"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws Array if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByTags(response: ResponseContext): Array { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public findPetsByTags(response: ResponseContext): Array { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid tag value"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws Pet if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public getPetById(response: ResponseContext): Pet { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public getPetById(response: ResponseContext): Pet { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public updatePet(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public updatePet(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Validation exception"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public updatePetWithForm(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public updatePetWithForm(response: ResponseContext): void { + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws ApiResponse if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public uploadFile(response: ResponseContext): ApiResponse { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public uploadFile(response: ResponseContext): ApiResponse { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; + return body; + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; + return body; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 41ca20d0b2a2..c73dee8b6c29 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -3,6 +3,9 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + import { Order } from '../models/Order'; export class StoreApiRequestFactory extends BaseAPIRequestFactory { @@ -133,63 +136,90 @@ export class StoreApiResponseProcessor { /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public deleteOrder(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public deleteOrder(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws { [key: string]: number; } if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public getInventory(response: ResponseContext): { [key: string]: number; } { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public getInventory(response: ResponseContext): { [key: string]: number; } { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; + return body; } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws Order if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public getOrderById(response: ResponseContext): Order { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public getOrderById(response: ResponseContext): Order { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws Order if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public placeOrder(response: ResponseContext): Order { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public placeOrder(response: ResponseContext): Order { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid Order"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + return body; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index 428bcd845b18..aed2f93c4b79 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -3,6 +3,9 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + import { User } from '../models/User'; export class UserApiRequestFactory extends BaseAPIRequestFactory { @@ -268,112 +271,153 @@ export class UserApiResponseProcessor { /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public createUser(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public createUser(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithArrayInput(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public createUsersWithArrayInput(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithListInput(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public createUsersWithListInput(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public deleteUser(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public deleteUser(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws User if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public getUserByName(response: ResponseContext): User { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public getUserByName(response: ResponseContext): User { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; + return body; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws string if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public loginUser(response: ResponseContext): string { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; - if (responseOK) { - return body; - } else { - // TODO: deal with different errors based on httpStatusCode - throw body + public loginUser(response: ResponseContext): string { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; + return body; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public logoutUser(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public logoutUser(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } /** * - * @throws if the httpStatusCode is not in [200, 299] + * @throws ApiException if the response code was not in [200, 299] */ - public updateUser(response: ResponseContext): void { - const jsonBody = JSON.parse(response.body); - const responseOK = response.httpStatusCode && response.httpStatusCode >= 200 && response.httpStatusCode <= 299; - // TODO: make this based on status code! - if (!responseOK) { - throw new Error("Invalid status code: " + response.httpStatusCode + "!"); + public updateUser(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid user supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; } + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/exception.ts b/samples/client/petstore/typescript/builds/default/apis/exception.ts new file mode 100644 index 000000000000..327ac516a314 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/exception.ts @@ -0,0 +1,5 @@ +export class ApiException extends Error { + public constructor(public code: number, public body: T) { + super("Got HTTP Status Code " + code) + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index 2bcea78b8ca8..e7c7bd4e5a96 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -5,3 +5,4 @@ export * from './middleware'; export * from './models/all'; export { Configuration} from './configuration' export * from './PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/util.ts b/samples/client/petstore/typescript/builds/default/util.ts new file mode 100644 index 000000000000..af9085e7cbff --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/util.ts @@ -0,0 +1,20 @@ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/dist/test.js b/samples/client/petstore/typescript/tests/default/dist/test.js deleted file mode 100644 index 5ebd748a5a91..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/test.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var MiddlewareA = /** @class */ (function () { - function MiddlewareA() { - } - MiddlewareA.prototype.pre = function (request) { - console.log(request); - return Promise.resolve(request); - }; - MiddlewareA.prototype.post = function (response) { - console.log(response); - return Promise.resolve(response); - }; - return MiddlewareA; -}()); -var config = new ts_petstore_client_1.Configuration({ - middleware: [ - new MiddlewareA() - ] -}); -var api = new ts_petstore_client_1.PetApi(config); -api.getPetById(3).then(function (pet) { - console.log(pet); -}).catch(function (err) { - console.log(err); -}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js b/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js deleted file mode 100644 index 41e07205f980..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/test/api/PetApi.test.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var chai_1 = require("chai"); -var configuration = new ts_petstore_client_1.Configuration(); -var petApi = new ts_petstore_client_1.PetApi(configuration); -describe("PetApi", function () { - it("addPet", function (done) { - var pet = new ts_petstore_client_1.Pet(); - pet.id = Math.floor(Math.random() * 100000); - pet.name = "PetName"; - pet.photoUrls = []; - pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; - pet.tags = []; - pet.category = undefined; - petApi.addPet(pet).then(function () { - return petApi.getPetById(pet.id); - }).then(function (createdPet) { - chai_1.expect(createdPet).to.deep.equal(pet); - done(); - }).catch(function (err) { - done(err); - }); - }); -}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js deleted file mode 100644 index e0e55de464a6..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/test/auth/auth.test.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var ts_petstore_client_2 = require("ts-petstore-client"); -var chai_1 = require("chai"); -describe("Security Authentication", function () { - describe("No Authentication", function () { - it("No Authentication", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var noAuth = new ts_petstore_client_1.NoAuthentication(); - noAuth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); - describe("API Key Authentication", function () { - // TODO: make all params const variables - it("Header API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); - chai_1.expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Query API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "query", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Cookie API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); - chai_1.expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); -}); diff --git a/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js deleted file mode 100644 index bca167ad8671..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/test/http/isomorphic-fetch.test.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var chai_1 = require("chai"); -var FormData = require("form-data"); -var libs = { - "isomorphic-fetch": new ts_petstore_client_1.IsomorphicFetchHttpLibrary() -}; -var _loop_1 = function (libName) { - var lib = libs[libName]; - describe("Isomorphic Fetch", function () { - it("GET-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/get", ts_petstore_client_1.HttpMethod.GET); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("POST-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/post", ts_petstore_client_1.HttpMethod.POST); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - var formData = new FormData(); - formData.append("test", "test2"); - formData.append("testFile", Buffer.from("abc"), "fileName.json"); - requestContext.setBody(formData); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - chai_1.expect(body["files"]["testFile"]).to.equal("abc"); - chai_1.expect(body["form"]["test"]).to.equal("test2"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("Cookies-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/cookies", ts_petstore_client_1.HttpMethod.GET); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); - done(); - }).catch(function (e) { - done(e); - }); - }); - }); -}; -for (var libName in libs) { - _loop_1(libName); -} diff --git a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js deleted file mode 100644 index 0a7f6547ffd7..000000000000 --- a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js +++ /dev/null @@ -1,193 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var rewire = require("rewire"); -var chai_1 = require("chai"); -var ts_petstore_client_1 = require("ts-petstore-client"); -var objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts"); -var ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer"); -describe("ObjectSerializer", function () { - describe("Serialize", function () { - it("String", function () { - var input = "test string"; - chai_1.expect(ObjectSerializer.serialize(input, "string")).to.equal("test string"); - }); - it("Number", function () { - var input = 1337; - chai_1.expect(ObjectSerializer.serialize(input, "number")).to.equal(1337); - }); - it("String Array", function () { - var input = ["a", "b", "c"]; - chai_1.expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal(["a", "b", "c"]); - }); - it("Number Array", function () { - var input = [1337, 42, 0]; - chai_1.expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal([1337, 42, 0]); - }); - it("Date", function () { - var input = new Date(1543777609696); - chai_1.expect(ObjectSerializer.serialize(input, "Date")).to.equal(input.toISOString()); - }); - it("Object", function () { - var input = { "a": "test", "b": { "test": 5 } }; - chai_1.expect(ObjectSerializer.serialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5 } }); - }); - it("Class", function () { - var input = new ts_petstore_client_1.Category(); - input.id = 4; - input.name = "Test"; - chai_1.expect(ObjectSerializer.serialize(input, "Category")).to.deep.equal({ "id": input.id, "name": input.name }); - }); - it("Enum", function () { - var input = ts_petstore_client_1.Pet.StatusEnum.Available; - chai_1.expect(ObjectSerializer.serialize(input, "Pet.StatusEnum")).to.equal("available"); - }); - it("Complex Class", function () { - var tags = []; - var tagResult = []; - for (var i = 0; i < 2; i++) { - var tag = new ts_petstore_client_1.Tag(); - tag.id = i; - tag.name = "Tag" + i; - tags.push(tag); - tagResult.push({ - "id": tag.id, - "name": tag.name - }); - } - var category = new ts_petstore_client_1.Category(); - category.id = 4; - category.name = "TestCat"; - var pet = new ts_petstore_client_1.Pet(); - pet.id = 145; - pet.category = category; - pet.name = "PetName"; - pet.photoUrls = ["url", "other url"]; - pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; - pet.tags = tags; - chai_1.expect(ObjectSerializer.serialize(pet, "Pet")).to.deep.equal({ - "id": pet.id, - "name": pet.name, - "category": { - "id": category.id, - "name": category.name - }, - "photoUrls": ["url", "other url"], - "status": "available", - "tags": tagResult - }); - }); - it("Array of Class", function () { - var categories = []; - var result = []; - for (var i = 0; i < 2; i++) { - var category = new ts_petstore_client_1.Category(); - category.id = i; - category.name = "Cat" + i; - categories.push(category); - result.push({ - "id": category.id, - "name": category.name - }); - } - chai_1.expect(ObjectSerializer.serialize(categories, "Array")).to.deep.equal(result); - }); - }); - describe("Deserialize", function () { - it("String", function () { - var input = "test string"; - chai_1.expect(ObjectSerializer.deserialize(input, "string")).to.equal("test string"); - }); - it("Number", function () { - var input = 1337; - chai_1.expect(ObjectSerializer.deserialize(input, "number")).to.equal(1337); - }); - it("String Array", function () { - var input = ["a", "b", "c"]; - chai_1.expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal(["a", "b", "c"]); - }); - it("Number Array", function () { - var input = [1337, 42, 0]; - chai_1.expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal([1337, 42, 0]); - }); - it("Date", function () { - var input = new Date(1543777609696); - chai_1.expect(ObjectSerializer.deserialize(input.toISOString(), "Date").getTime()).to.equal(input.getTime()); - }); - it("Object", function () { - var input = { "a": "test", "b": { "test": 5 } }; - chai_1.expect(ObjectSerializer.deserialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5 } }); - }); - it("Class", function () { - var input = new ts_petstore_client_1.Category(); - input.id = 4; - input.name = "Test"; - var deserialized = ObjectSerializer.deserialize({ "id": 4, "name": "Test" }, "Category"); - chai_1.expect(deserialized.constructor.name).to.equal("Category"); - chai_1.expect(deserialized).to.deep.equal(input); - }); - it("Enum", function () { - var input = ts_petstore_client_1.Pet.StatusEnum.Available; - chai_1.expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum")).to.equal(input); - }); - it("Complex Class", function () { - var tags = []; - var tagResult = []; - for (var i = 0; i < 2; i++) { - var tag = new ts_petstore_client_1.Tag(); - tag.id = i; - tag.name = "Tag" + i; - tags.push(tag); - tagResult.push({ - "id": tag.id, - "name": tag.name - }); - } - var category = new ts_petstore_client_1.Category(); - category.id = 4; - category.name = "TestCat"; - var pet = new ts_petstore_client_1.Pet(); - pet.id = 145; - pet.category = category; - pet.name = "PetName"; - pet.photoUrls = ["url", "other url"]; - pet.status = ts_petstore_client_1.Pet.StatusEnum.Available; - pet.tags = tags; - var deserialized = ObjectSerializer.deserialize({ - "id": pet.id, - "name": pet.name, - "category": { - "id": category.id, - "name": category.name - }, - "photoUrls": ["url", "other url"], - "status": "available", - "tags": tagResult - }, "Pet"); - chai_1.expect(deserialized.constructor.name).to.equal("Pet"); - chai_1.expect(deserialized.category.constructor.name).to.equal("Category"); - for (var i = 0; i < deserialized.tags.length; i++) { - chai_1.expect(deserialized.tags[i].constructor.name).to.equal("Tag"); - } - chai_1.expect(deserialized).to.deep.equal(pet); - }); - it("Array of Class", function () { - var categories = []; - var result = []; - for (var i = 0; i < 2; i++) { - var category = new ts_petstore_client_1.Category(); - category.id = i; - category.name = "Cat" + i; - categories.push(category); - result.push({ - "id": category.id, - "name": category.name - }); - } - var deserialized = ObjectSerializer.deserialize(result, "Array"); - for (var i = 0; i < categories.length; i++) { - chai_1.expect(deserialized[i].constructor.name).to.equal("Category"); - } - chai_1.expect(deserialized).to.deep.equal(categories); - }); - }); -}); diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index d243f18abf15..5f963a302a5c 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -1,18 +1,20 @@ -import {PetApi, Configuration, Pet} from 'ts-petstore-client' +import {PetApi, Configuration, Pet, ApiException} from 'ts-petstore-client' import { expect, assert } from "chai"; const configuration = new Configuration() const petApi = new PetApi(configuration) +const pet = new Pet() +pet.id = Math.floor(Math.random() * 100000) +pet.name = "PetName" +pet.photoUrls = [] +pet.status = Pet.StatusEnum.Available +pet.tags = [] +pet.category = undefined + describe("PetApi", () =>{ it("addPet", (done) => { - const pet = new Pet() - pet.id = Math.floor(Math.random() * 100000) - pet.name = "PetName" - pet.photoUrls = [] - pet.status = Pet.StatusEnum.Available - pet.tags = [] - pet.category = undefined + petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) @@ -23,4 +25,20 @@ describe("PetApi", () =>{ done(err) }) }) + + it("deletePet", (done) => { + petApi.addPet(pet).then(() => { + return petApi.deletePet(pet.id) + }).then(() => { + return petApi.getPetById(pet.id) + }).then((pet: Pet) => { + done("Pet with id " + pet.id + " was not deleted!"); + }).catch((err: any) => { + if (err instanceof ApiException && err.code == 404) { + done(); + } else { + done(err) + } + }) + }) }) \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/client/petstore/typescript/tests/default/tsconfig.json index 3470aabd0c3c..4596f6e40bcf 100644 --- a/samples/client/petstore/typescript/tests/default/tsconfig.json +++ b/samples/client/petstore/typescript/tests/default/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "sourceMap": false, "outDir": "dist", From 8bfb88cd76e580c0d12a4957b63e977a316d02ed Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 6 Dec 2018 23:28:09 +0100 Subject: [PATCH 26/85] Removed tabs in TypeScriptClientCodegen --- .../languages/TypeScriptClientCodegen.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 70d65171e1a8..5fd3214b5e21 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -168,12 +168,12 @@ public Map postProcessOperations(Map operations) } @SuppressWarnings("unchecked") - Map operationsMap = (Map) operations.get("operations"); + Map operationsMap = (Map) operations.get("operations"); List operationList = (List) operationsMap.get("operation"); - for (CodegenOperation operation: operationList) { + for (CodegenOperation operation: operationList) { List responses = operation.responses; - operation.returnType = this.getReturnType(responses); - } + operation.returnType = this.getReturnType(responses); + } return operations; } @@ -183,29 +183,29 @@ private String getReturnType(List responses) { boolean atLeastOneSuccess = false; boolean addVoid = false; System.out.println(responses); - for (CodegenResponse response: responses) { - // TODO: we should probably catch an exception here - if (response.isSuccessCode) { - if (response.dataType != null) { - if (!firstReturnType) { - returnType.append(" | "); - } - returnType.append(response.dataType); - firstReturnType = false; - atLeastOneSuccess = true; - } else { - addVoid = true; - } - } - } - if (!atLeastOneSuccess) { - return null; - } else if (addVoid) { - returnType.append(" | void"); - } - - System.out.println("Return Type: " + returnType); - return returnType.toString(); + for (CodegenResponse response: responses) { + // TODO: we should probably catch an exception here + if (response.isSuccessCode) { + if (response.dataType != null) { + if (!firstReturnType) { + returnType.append(" | "); + } + returnType.append(response.dataType); + firstReturnType = false; + atLeastOneSuccess = true; + } else { + addVoid = true; + } + } + } + if (!atLeastOneSuccess) { + return null; + } else if (addVoid) { + returnType.append(" | void"); + } + + System.out.println("Return Type: " + returnType); + return returnType.toString(); } private String getModelnameFromModelFilename(String filename) { From c5c9a59060aa80d33f87111437a81ae6ac12023b Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 6 Dec 2018 23:55:31 +0100 Subject: [PATCH 27/85] Removed tabs in DefaultCodegen --- .../src/main/java/org/openapitools/codegen/DefaultCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 14be4a366233..a62ab388a600 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4209,7 +4209,7 @@ public boolean isDataTypeBinary(String dataType) { return false; } } - + // TODO revise below as it should be replaced by ModelUtils.isFileSchema(parameterSchema) public boolean isDataTypeFile(String dataType) { if (dataType != null) { From 1c2943dcc889ec3b3dd0d8f33fadcf34d08b7be1 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Fri, 7 Dec 2018 12:13:24 +0100 Subject: [PATCH 28/85] Additional tests for pet store api --- .../resources/typescript/api/api.mustache | 10 ++- .../typescript/api/exception.mustache | 2 +- .../typescript/builds/default/apis/PetApi.ts | 54 +++++++----- .../builds/default/apis/StoreApi.ts | 24 ++++-- .../typescript/builds/default/apis/UserApi.ts | 52 ++++++++---- .../builds/default/apis/exception.ts | 2 +- .../tests/default/test/api/PetApi.test.ts | 85 ++++++++++++++++++- 7 files changed, 176 insertions(+), 53 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 218b0636e71f..93cc09a5060f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -32,17 +32,18 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params {{#queryParams}} if ({{paramName}} !== undefined) { - requestContext.setQueryParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); } {{/queryParams}} // Header Params {{#headerParams}} - requestContext.setHeaderParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + requestContext.setHeaderParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); {{/headerParams}} // Form Params @@ -154,7 +155,8 @@ export class {{classname}}ResponseProcessor { return; {{/returnType}} } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache index 327ac516a314..c5dd10fa4387 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache @@ -1,5 +1,5 @@ export class ApiException extends Error { public constructor(public code: number, public body: T) { - super("Got HTTP Status Code " + code) + super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) } } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index a417d3b75c2e..f7a19f1ece04 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -24,7 +24,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -62,11 +63,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params - requestContext.setHeaderParam("", ObjectSerializer.serialize(apiKey, "string")); + requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string")); // Form Params @@ -95,10 +97,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params if (status !== undefined) { - requestContext.setQueryParam("", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); + requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); } // Header Params @@ -130,10 +133,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params if (tags !== undefined) { - requestContext.setQueryParam("", ObjectSerializer.serialize(tags, "Array")); + requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array")); } // Header Params @@ -166,7 +170,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -198,7 +203,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -236,7 +242,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -279,7 +286,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -330,7 +338,8 @@ export class PetApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -346,7 +355,8 @@ export class PetApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -369,7 +379,8 @@ export class PetApiResponseProcessor { const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -392,7 +403,8 @@ export class PetApiResponseProcessor { const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -418,7 +430,8 @@ export class PetApiResponseProcessor { const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -440,7 +453,8 @@ export class PetApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -456,7 +470,8 @@ export class PetApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -476,7 +491,8 @@ export class PetApiResponseProcessor { const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index c73dee8b6c29..67ca8296df60 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -24,7 +24,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -46,7 +47,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -79,7 +81,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -106,7 +109,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -150,7 +154,8 @@ export class StoreApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -170,7 +175,8 @@ export class StoreApiResponseProcessor { const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -196,7 +202,8 @@ export class StoreApiResponseProcessor { const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -219,7 +226,8 @@ export class StoreApiResponseProcessor { const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index aed2f93c4b79..c5bdf836ef62 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -23,7 +23,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -55,7 +56,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -87,7 +89,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -120,7 +123,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -148,7 +152,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -180,13 +185,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params if (username !== undefined) { - requestContext.setQueryParam("", ObjectSerializer.serialize(username, "string")); + requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string")); } if (password !== undefined) { - requestContext.setQueryParam("", ObjectSerializer.serialize(password, "string")); + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string")); } // Header Params @@ -208,7 +214,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -241,7 +248,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - + requestContext.setHeaderParam("Accept", "application/json") + // Query Params // Header Params @@ -282,7 +290,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -298,7 +307,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -314,7 +324,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -333,7 +344,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -359,7 +371,8 @@ export class UserApiResponseProcessor { const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -382,7 +395,8 @@ export class UserApiResponseProcessor { const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; return body; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -398,7 +412,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } /** @@ -417,7 +432,8 @@ export class UserApiResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { return; } - throw new ApiException(response.httpStatusCode, "Unknown API Status Code!"); + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } } diff --git a/samples/client/petstore/typescript/builds/default/apis/exception.ts b/samples/client/petstore/typescript/builds/default/apis/exception.ts index 327ac516a314..c5dd10fa4387 100644 --- a/samples/client/petstore/typescript/builds/default/apis/exception.ts +++ b/samples/client/petstore/typescript/builds/default/apis/exception.ts @@ -1,5 +1,5 @@ export class ApiException extends Error { public constructor(public code: number, public body: T) { - super("Got HTTP Status Code " + code) + super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) } } \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 5f963a302a5c..bdd6f52fb34f 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -1,15 +1,19 @@ -import {PetApi, Configuration, Pet, ApiException} from 'ts-petstore-client' +import {PetApi, Configuration, Pet, ApiException, Tag} from 'ts-petstore-client' import { expect, assert } from "chai"; const configuration = new Configuration() const petApi = new PetApi(configuration) +const tag = new Tag(); +tag.name = "tag1" +tag.id = Math.floor(Math.random() * 100000) + const pet = new Pet() pet.id = Math.floor(Math.random() * 100000) pet.name = "PetName" pet.photoUrls = [] pet.status = Pet.StatusEnum.Available -pet.tags = [] +pet.tags = [ tag ] pet.category = undefined describe("PetApi", () =>{ @@ -41,4 +45,81 @@ describe("PetApi", () =>{ } }) }) + + it("findPetsByStatus", (done) => { + petApi.addPet(pet).then(() => { + return petApi.findPetsByStatus(["available"]) + }).then((pets: Pet[]) => { + expect(pets.length).to.be.at.least(1); + done(); + }).catch((err) => { + done(err) + }) + }) + + // bugged on server side! Code 500 +/* it("findPetsByTag", (done) => { + petApi.addPet(pet).then(() => { + return petApi.findPetsByTags([tag.name]) + }).then((pets: Pet[]) => { + expect(pets.length).to.be.at.least(1); + done(); + }).catch((err) => { + done(err); + }) + })*/ + + it("getPetById", (done) => { + petApi.addPet(pet).then(() => { + return petApi.getPetById(pet.id) + }).then((returnedPet: Pet) => { + expect(returnedPet).to.deep.equal(pet); + done(); + }).catch((err) => { + done(err); + }) + }) + + it("updatePet", (done) => { + const oldName = pet.name + const updatedName = "updated name"; + petApi.addPet(pet).then(() => { + pet.name = updatedName + return petApi.updatePet(pet).then(() => { + pet.name = oldName; + }).catch((err) => { + pet.name = oldName + throw err; + }); + }).then(() => { + return petApi.getPetById(pet.id); + }).then((returnedPet: Pet) => { + expect(returnedPet.id).to.equal(pet.id) + expect(returnedPet.name).to.equal(updatedName); + done(); + }).catch((err) => { + done(err) + }) + }) + +// not supported by online swagger api? +/* it("updatePetWithForm", (done) => { + const updatedName = "updated name"; + petApi.addPet(pet).then(() => { + return petApi.updatePetWithForm(pet.id, updatedName) + }).then(() => { + return petApi.getPetById(pet.id) + }).then((returnedPet: Pet) => { + expect(returnedPet.id).to.equal(pet.id) + expect(returnedPet.name).to.equal(updatedName); + done() + }).catch((err) => { + done(err) + }) + })*/ + +/* it("", (done) => { + file + petApi.uploadFile(pet.id, "", file) + })*/ }) \ No newline at end of file From 7786f2e9fb97a6ae76764f72ef57157490856e3a Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 3 Mar 2019 23:30:43 +0100 Subject: [PATCH 29/85] Fixed file uploads --- .../languages/TypeScriptClientCodegen.java | 4 +++- .../resources/typescript/api/api.mustache | 9 ++++++-- .../typescript/generators/PromiseAPI.mustache | 2 +- .../resources/typescript/http/http.mustache | 4 ++++ .../typescript/builds/default/PromiseAPI.ts | 4 ++-- .../typescript/builds/default/apis/PetApi.ts | 12 +++++----- .../builds/default/apis/StoreApi.ts | 2 +- .../typescript/builds/default/apis/UserApi.ts | 2 +- .../typescript/builds/default/http/http.ts | 4 ++++ .../tests/default/package-lock.json | 10 +++------ .../tests/default/test/api/PetApi.test.ts | 21 +++++++++++------- .../typescript/tests/default/test/api/pet.png | Bin 0 -> 1122 bytes 12 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 samples/client/petstore/typescript/tests/default/test/api/pet.png diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 5fd3214b5e21..159b2763ed67 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -107,6 +107,7 @@ public TypeScriptClientCodegen() { typeMapping.put("date", "string"); typeMapping.put("DateTime", "Date"); typeMapping.put("binary", "any"); + // TODO: allow other types for file e.g. Blob typeMapping.put("File", "any"); typeMapping.put("ByteArray", "string"); typeMapping.put("UUID", "string"); @@ -677,7 +678,8 @@ public String getTypeDeclaration(Schema p) { inner = (Schema) p.getAdditionalProperties(); return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; } else if (ModelUtils.isFileSchema(p)) { - return "any"; + // TODO: Change type declaration + return "HttpFile"; } else if (ModelUtils.isBinarySchema(p)) { return "any"; } else { diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 93cc09a5060f..79d3353951dd 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -1,6 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; @@ -68,7 +68,12 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{^isListContainer}} if ({{paramName}} !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('{{baseName}}', {{paramName}} as any); + {{^isFile}} + localVarFormParams.append('{{baseName}}', {{paramName}} as any); + {{/isFile}} + {{#isFile}} + localVarFormParams.append('{{baseName}}', {{paramName}}.data, { "filename": {{paramName}}.name }); + {{/isFile}} } {{/isListContainer}} {{/formParams}} diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache index 4922915ba5c9..07e9a60ba7db 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache @@ -1,4 +1,4 @@ -import { ResponseContext } from './http/http'; +import { ResponseContext, HttpFile } from './http/http'; import * as models from './models/all'; import { Configuration} from './configuration' diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index e23d864203cb..8e11238e3c77 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -15,6 +15,10 @@ export enum HttpMethod { TRACE = "TRACE", PATCH = "PATCH" } +export interface HttpFile { + data: Buffer; + name: string; +} export interface FormEntry { contentDisposition: string; diff --git a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts index d6888f214b54..2b89bbc5fd71 100644 --- a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts @@ -1,4 +1,4 @@ -import { ResponseContext } from './http/http'; +import { ResponseContext, HttpFile } from './http/http'; import * as models from './models/all'; import { Configuration} from './configuration' @@ -152,7 +152,7 @@ export class PetApi { }); } - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise { + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: any): Promise { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index f7a19f1ece04..b5a654bb50b0 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -1,6 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; @@ -253,11 +253,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { if (name !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('name', name as any); + localVarFormParams.append('name', name as any); } if (status !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('status', status as any); + localVarFormParams.append('status', status as any); } requestContext.setBody(localVarFormParams); @@ -273,7 +273,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext { + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: any): RequestContext { // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); @@ -297,11 +297,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { if (additionalMetadata !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('additionalMetadata', additionalMetadata as any); + localVarFormParams.append('additionalMetadata', additionalMetadata as any); } if (file !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('file', file as any); + localVarFormParams.append('file', file.data, { "filename": file.name }); } requestContext.setBody(localVarFormParams); diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 67ca8296df60..9908e2319240 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -1,6 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index c5bdf836ef62..fb70caee35aa 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -1,6 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; -import { RequestContext, HttpMethod, ResponseContext} from '../http/http'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index e23d864203cb..8e11238e3c77 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -15,6 +15,10 @@ export enum HttpMethod { TRACE = "TRACE", PATCH = "PATCH" } +export interface HttpFile { + data: Buffer; + name: string; +} export interface FormEntry { contentDisposition: string; diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 8c91101d4447..de0cb9aad919 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -1313,14 +1313,14 @@ } }, "mime-db": { - "version": "1.36.0", + "version": "1.37.0", "bundled": true }, "mime-types": { - "version": "2.1.20", + "version": "2.1.21", "bundled": true, "requires": { - "mime-db": "~1.36.0" + "mime-db": "~1.37.0" } }, "node-fetch": { @@ -1343,10 +1343,6 @@ "version": "2.1.2", "bundled": true }, - "typescript": { - "version": "2.9.2", - "bundled": true - }, "url-parse": { "version": "1.4.3", "bundled": true, diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index bdd6f52fb34f..012dabaf4ef7 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -1,5 +1,6 @@ -import {PetApi, Configuration, Pet, ApiException, Tag} from 'ts-petstore-client' +import {PetApi, Configuration, Pet, ApiException, Tag, HttpFile} from 'ts-petstore-client' import { expect, assert } from "chai"; +import * as fs from 'fs'; const configuration = new Configuration() const petApi = new PetApi(configuration) @@ -18,8 +19,6 @@ pet.category = undefined describe("PetApi", () =>{ it("addPet", (done) => { - - petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) }).then((createdPet) => { @@ -38,7 +37,7 @@ describe("PetApi", () =>{ }).then((pet: Pet) => { done("Pet with id " + pet.id + " was not deleted!"); }).catch((err: any) => { - if (err instanceof ApiException && err.code == 404) { + if (err.code && err.code == 404) { done(); } else { done(err) @@ -118,8 +117,14 @@ describe("PetApi", () =>{ }) })*/ -/* it("", (done) => { - file - petApi.uploadFile(pet.id, "", file) - })*/ + it("uploadFile", (done) => { + const image = fs.readFileSync(__dirname + "/pet.png") + petApi.uploadFile(pet.id, "Metadata", { name: "pet.png", data: image}).then((response: any) => { + expect(response.code).to.be.gte(200).and.lt(300); + expect(response.message).to.contain("pet.png"); + done(); + }).catch((err) => { + done(err); + }) + }) }) \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test/api/pet.png b/samples/client/petstore/typescript/tests/default/test/api/pet.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a9c49163db88f92e798e1c2aa4920ee6190829 GIT binary patch literal 1122 zcmV-o1fBbdP)Pv>k;Jhr>-0WM zqfHxc(XJkZAh2f0;gAyF_nm#aN+~I&5JCvSdygNrRv`otbzNtS>AFs9t+kd?a?T%* z)A#7L)>>=MIfSsT>+N=1*LB-A5GbWmN`2o8Avot!O8oc*!M^V~=NO~+exB!Pnm~|q zCL*nM&UxQ=B9c;K=bS%s{33&8S(arvpU=y(AOmad>+35KS!W+5c8t}76wlv2uV+qP|sF_u#B{a1pN5)la@o}qyrW6U{w@3(CWA;cI_WK=ch zTuQ06g5V1dV~k2Eob!F(rIe4d06nGTy@zw=d0y8QOr;beGREZlLO(rs6>Zz5lu}AD z#-J6{#4&&_%i_I9m&F)kjGS{sopWxu&-yUNXrAY;>ku*$-1i-^LvD1y^?IG>IfSrn zTT1CMl#~*%ng*W;VCtN+F@}g>%~sOu^?E*^=Xpl>>$;|t5H%4!;tC;-GkAZ0AIH%- zmve@NODWBim&*msb-7&N&YUwW)O3fowbp-TugAj{=f)Uo?KqCZFuc6H48t%CgSGbgGGL5R z2tf#e*?{wiw>1$Fp?dHo5fPDd?sPi6y}f}zYmJf|5CFHSeBQE5_0x-rt=4g|TbKZ3w z4AX`Ox)hbvTKD(moa_4@lt}J?0NP0@@loIR2p?%ddfd9`ENgAob#SLK#yNL**Z(De zENB^H4DP=M*EkTn5CYE=M2%C2{q?B^_zuSqpi;_O3sA-w^u-N>#}AIQ2>yl67$fH# zo-}Aq?6}178_@09({S!_n_SH&_zh5eBkt=b(0^-yCcu4wkgc_N79w7N z!cJ}f;iA*&gpNhLz-5fVR89SMq5gJJ*L9c>=p(c{+OkRUf6yNUecxly!!t;t$@0BJ oenc<~0|qjrfO8I?vH!RJ0MkcqZO@AHAOHXW07*qoM6N<$f;dkN^Z)<= literal 0 HcmV?d00001 From a00e342505cdc20ef481c848adb145632c00d644 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 3 Mar 2019 23:51:35 +0100 Subject: [PATCH 30/85] Made api call configuration separately settable --- .../resources/typescript/api/api.mustache | 9 ++- .../typescript/generators/PromiseAPI.mustache | 2 +- .../typescript/builds/default/apis/PetApi.ts | 70 ++++++++++++------- .../builds/default/apis/StoreApi.ts | 26 ++++--- .../typescript/builds/default/apis/UserApi.ts | 50 ++++++++----- 5 files changed, 104 insertions(+), 53 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 79d3353951dd..074b3fa3a145 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -1,5 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; @@ -15,8 +16,10 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory {{#operation}} - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): RequestContext { + let config = options || this.configuration; {{#allParams}} + {{#required}} // verify required parameter '{{paramName}}' is not null or undefined if ({{paramName}} === null || {{paramName}} === undefined) { @@ -31,7 +34,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -100,7 +103,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{/hasAuthMethods}} // Apply auth methods {{#authMethods}} - authMethod = this.configuration.authMethods["{{name}}"] + authMethod = config.authMethods["{{name}}"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache index 07e9a60ba7db..e60ef05dd76f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache @@ -22,7 +22,7 @@ export class {{classname}} { } {{#operation}} - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); // build promise chain diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index b5a654bb50b0..5bcbe793f1d8 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -1,5 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; @@ -12,7 +13,9 @@ import { Pet } from '../models/Pet'; export class PetApiRequestFactory extends BaseAPIRequestFactory { // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory - public addPet(pet: Pet, options?: any): RequestContext { + public addPet(pet: Pet, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'pet' is not null or undefined if (pet === null || pet === undefined) { throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); @@ -23,7 +26,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/pet'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -42,7 +45,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -50,19 +53,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public deletePet(petId: number, apiKey?: string, options?: any): RequestContext { + public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); } + // Path Params const localVarPath = '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -77,7 +83,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -85,7 +91,9 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext { + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'status' is not null or undefined if (status === null || status === undefined) { throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); @@ -96,7 +104,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/pet/findByStatus'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -113,7 +121,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -121,7 +129,9 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public findPetsByTags(tags: Array, options?: any): RequestContext { + public findPetsByTags(tags: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'tags' is not null or undefined if (tags === null || tags === undefined) { throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); @@ -132,7 +142,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/pet/findByTags'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -149,7 +159,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -157,7 +167,9 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public getPetById(petId: number, options?: any): RequestContext { + public getPetById(petId: number, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); @@ -169,7 +181,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -183,7 +195,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["api_key"] + authMethod = config.authMethods["api_key"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -191,7 +203,9 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public updatePet(pet: Pet, options?: any): RequestContext { + public updatePet(pet: Pet, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'pet' is not null or undefined if (pet === null || pet === undefined) { throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); @@ -202,7 +216,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/pet'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -221,7 +235,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -229,19 +243,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext { + public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); } + + // Path Params const localVarPath = '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -265,7 +283,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -273,19 +291,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: any): RequestContext { + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); } + + // Path Params const localVarPath = '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -309,7 +331,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["petstore_auth"] + authMethod = config.authMethods["petstore_auth"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 9908e2319240..9b9fbc5c5eeb 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -1,5 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; @@ -11,7 +12,9 @@ import { Order } from '../models/Order'; export class StoreApiRequestFactory extends BaseAPIRequestFactory { // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory - public deleteOrder(orderId: string, options?: any): RequestContext { + public deleteOrder(orderId: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'orderId' is not null or undefined if (orderId === null || orderId === undefined) { throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); @@ -23,7 +26,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -40,13 +43,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public getInventory(options?: any): RequestContext { + public getInventory(options?: Configuration): RequestContext { + let config = options || this.configuration; // Path Params const localVarPath = '/store/inventory'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -60,7 +64,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { let authMethod = null; // Apply auth methods - authMethod = this.configuration.authMethods["api_key"] + authMethod = config.authMethods["api_key"] if (authMethod) { authMethod.applySecurityAuthentication(requestContext); } @@ -68,7 +72,9 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public getOrderById(orderId: number, options?: any): RequestContext { + public getOrderById(orderId: number, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'orderId' is not null or undefined if (orderId === null || orderId === undefined) { throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); @@ -80,7 +86,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -97,7 +103,9 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public placeOrder(order: Order, options?: any): RequestContext { + public placeOrder(order: Order, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'order' is not null or undefined if (order === null || order === undefined) { throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); @@ -108,7 +116,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/store/order'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index fb70caee35aa..469719a3fcd3 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -1,5 +1,6 @@ // TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; @@ -11,7 +12,9 @@ import { User } from '../models/User'; export class UserApiRequestFactory extends BaseAPIRequestFactory { // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory - public createUser(user: User, options?: any): RequestContext { + public createUser(user: User, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'user' is not null or undefined if (user === null || user === undefined) { throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); @@ -22,7 +25,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/user'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -44,7 +47,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public createUsersWithArrayInput(user: Array, options?: any): RequestContext { + public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'user' is not null or undefined if (user === null || user === undefined) { throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); @@ -55,7 +60,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/user/createWithArray'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -77,7 +82,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public createUsersWithListInput(user: Array, options?: any): RequestContext { + public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'user' is not null or undefined if (user === null || user === undefined) { throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); @@ -88,7 +95,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/user/createWithList'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -110,7 +117,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public deleteUser(username: string, options?: any): RequestContext { + public deleteUser(username: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); @@ -122,7 +131,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'username' + '}', encodeURIComponent(String(username))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -139,7 +148,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public getUserByName(username: string, options?: any): RequestContext { + public getUserByName(username: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); @@ -151,7 +162,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'username' + '}', encodeURIComponent(String(username))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -168,12 +179,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public loginUser(username: string, password: string, options?: any): RequestContext { + public loginUser(username: string, password: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); } + // verify required parameter 'password' is not null or undefined if (password === null || password === undefined) { throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); @@ -184,7 +198,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { const localVarPath = '/user/login'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -207,13 +221,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public logoutUser(options?: any): RequestContext { + public logoutUser(options?: Configuration): RequestContext { + let config = options || this.configuration; // Path Params const localVarPath = '/user/logout'; // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json") // Query Params @@ -230,12 +245,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } - public updateUser(username: string, user: User, options?: any): RequestContext { + public updateUser(username: string, user: User, options?: Configuration): RequestContext { + let config = options || this.configuration; + // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); } + // verify required parameter 'user' is not null or undefined if (user === null || user === undefined) { throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); @@ -247,7 +265,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { .replace('{' + 'username' + '}', encodeURIComponent(String(username))); // Make Request Context - const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); requestContext.setHeaderParam("Accept", "application/json") // Query Params From e11a5a9395c38ffb7fef747bd391db3afdf20157 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 4 Mar 2019 00:12:07 +0100 Subject: [PATCH 31/85] Use string union for enums --- .../languages/TypeScriptClientCodegen.java | 4 +- .../model/ObjectSerializer.mustache | 14 +++---- .../resources/typescript/model/model.mustache | 12 ++---- .../typescript/builds/default/PromiseAPI.ts | 40 +++++++++---------- .../builds/default/models/ObjectSerializer.ts | 18 ++++----- .../typescript/builds/default/models/Order.ts | 14 +++---- .../typescript/builds/default/models/Pet.ts | 14 +++---- .../tests/default/test/api/PetApi.test.ts | 2 +- .../test/models/ObjectSerializer.test.ts | 8 ++-- 9 files changed, 56 insertions(+), 70 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 159b2763ed67..4b0dcc7809c6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -546,14 +546,14 @@ public Map postProcessModels(Map objs) { // name enum with model name, e.g. StatusEnum => Pet.StatusEnum for (CodegenProperty var : cm.vars) { if (Boolean.TRUE.equals(var.isEnum)) { - var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName); + var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + var.enumName); } } if (cm.parent != null) { for (CodegenProperty var : cm.allVars) { if (Boolean.TRUE.equals(var.isEnum)) { var.datatypeWithEnum = var.datatypeWithEnum - .replace(var.enumName, cm.classname + "." + var.enumName); + .replace(var.enumName, cm.classname + var.enumName); } } } diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 842c4a89691a..4655727b1899 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -6,7 +6,7 @@ export * from './{{{ classFilename }}}'; {{#models}} {{#model}} -import { {{classname}} } from './{{{ classFilename }}}'; +import { {{classname}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}} } from './{{{ classFilename }}}'; {{/model}} {{/models}} @@ -22,19 +22,19 @@ let primitives = [ "any" ]; -let enumsMap: {[index: string]: any} = { +let enumsMap: Set = new Set([ {{#models}} {{#model}} {{#hasEnums}} {{#vars}} {{#isEnum}} - {{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{#isNotContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isNotContainer}}, + "{{classname}}{{enumName}}", {{/isEnum}} {{/vars}} {{/hasEnums}} {{/model}} {{/models}} -} +]); let typeMap: {[index: string]: any} = { {{#models}} @@ -53,7 +53,7 @@ export class ObjectSerializer { } else if (expectedType === "Date") { return expectedType; } else { - if (enumsMap[expectedType]) { + if (enumsMap.has(expectedType)) { return expectedType; } @@ -97,7 +97,7 @@ export class ObjectSerializer { } else if (type === "Date") { return data.toISOString(); } else { - if (enumsMap[type]) { + if (enumsMap.has(type)) { return data; } if (!typeMap[type]) { // in case we dont know the type @@ -137,7 +137,7 @@ export class ObjectSerializer { } else if (type === "Date") { return new Date(data); } else { - if (enumsMap[type]) {// is Enum + if (enumsMap.has(type)) {// is Enum return data; } diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 0b3ca7589164..b94d89990f97 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -51,19 +51,13 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ } {{#hasEnums}} -export namespace {{classname}} { + {{#vars}} {{#isEnum}} - export enum {{enumName}} { - {{#allowableValues}} - {{#enumVars}} - {{name}} = {{{value}}}{{^-last}},{{/-last}} - {{/enumVars}} - {{/allowableValues}} - } +export type {{classname}}{{enumName}} ={{#allowableValues}}{{#values}} "{{.}}" {{^-last}}|{{/-last}}{{/values}}{{/allowableValues}}; {{/isEnum}} {{/vars}} -} + {{/hasEnums}} {{/model}} {{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts index 2b89bbc5fd71..48f63d417e67 100644 --- a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts @@ -19,7 +19,7 @@ export class PetApi { this.responseProcessor = new PetApiResponseProcessor(); } - public addPet(pet: Pet, options?: any): Promise { + public addPet(pet: Pet, options?: Configuration): Promise { const requestContext = this.requestFactory.addPet(pet, options); // build promise chain @@ -38,7 +38,7 @@ export class PetApi { }); } - public deletePet(petId: number, apiKey?: string, options?: any): Promise { + public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { const requestContext = this.requestFactory.deletePet(petId, apiKey, options); // build promise chain @@ -57,7 +57,7 @@ export class PetApi { }); } - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise> { + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { const requestContext = this.requestFactory.findPetsByStatus(status, options); // build promise chain @@ -76,7 +76,7 @@ export class PetApi { }); } - public findPetsByTags(tags: Array, options?: any): Promise> { + public findPetsByTags(tags: Array, options?: Configuration): Promise> { const requestContext = this.requestFactory.findPetsByTags(tags, options); // build promise chain @@ -95,7 +95,7 @@ export class PetApi { }); } - public getPetById(petId: number, options?: any): Promise { + public getPetById(petId: number, options?: Configuration): Promise { const requestContext = this.requestFactory.getPetById(petId, options); // build promise chain @@ -114,7 +114,7 @@ export class PetApi { }); } - public updatePet(pet: Pet, options?: any): Promise { + public updatePet(pet: Pet, options?: Configuration): Promise { const requestContext = this.requestFactory.updatePet(pet, options); // build promise chain @@ -133,7 +133,7 @@ export class PetApi { }); } - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise { + public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); // build promise chain @@ -152,7 +152,7 @@ export class PetApi { }); } - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: any): Promise { + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain @@ -187,7 +187,7 @@ export class StoreApi { this.responseProcessor = new StoreApiResponseProcessor(); } - public deleteOrder(orderId: string, options?: any): Promise { + public deleteOrder(orderId: string, options?: Configuration): Promise { const requestContext = this.requestFactory.deleteOrder(orderId, options); // build promise chain @@ -206,7 +206,7 @@ export class StoreApi { }); } - public getInventory(options?: any): Promise<{ [key: string]: number; }> { + public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { const requestContext = this.requestFactory.getInventory(options); // build promise chain @@ -225,7 +225,7 @@ export class StoreApi { }); } - public getOrderById(orderId: number, options?: any): Promise { + public getOrderById(orderId: number, options?: Configuration): Promise { const requestContext = this.requestFactory.getOrderById(orderId, options); // build promise chain @@ -244,7 +244,7 @@ export class StoreApi { }); } - public placeOrder(order: Order, options?: any): Promise { + public placeOrder(order: Order, options?: Configuration): Promise { const requestContext = this.requestFactory.placeOrder(order, options); // build promise chain @@ -279,7 +279,7 @@ export class UserApi { this.responseProcessor = new UserApiResponseProcessor(); } - public createUser(user: User, options?: any): Promise { + public createUser(user: User, options?: Configuration): Promise { const requestContext = this.requestFactory.createUser(user, options); // build promise chain @@ -298,7 +298,7 @@ export class UserApi { }); } - public createUsersWithArrayInput(user: Array, options?: any): Promise { + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain @@ -317,7 +317,7 @@ export class UserApi { }); } - public createUsersWithListInput(user: Array, options?: any): Promise { + public createUsersWithListInput(user: Array, options?: Configuration): Promise { const requestContext = this.requestFactory.createUsersWithListInput(user, options); // build promise chain @@ -336,7 +336,7 @@ export class UserApi { }); } - public deleteUser(username: string, options?: any): Promise { + public deleteUser(username: string, options?: Configuration): Promise { const requestContext = this.requestFactory.deleteUser(username, options); // build promise chain @@ -355,7 +355,7 @@ export class UserApi { }); } - public getUserByName(username: string, options?: any): Promise { + public getUserByName(username: string, options?: Configuration): Promise { const requestContext = this.requestFactory.getUserByName(username, options); // build promise chain @@ -374,7 +374,7 @@ export class UserApi { }); } - public loginUser(username: string, password: string, options?: any): Promise { + public loginUser(username: string, password: string, options?: Configuration): Promise { const requestContext = this.requestFactory.loginUser(username, password, options); // build promise chain @@ -393,7 +393,7 @@ export class UserApi { }); } - public logoutUser(options?: any): Promise { + public logoutUser(options?: Configuration): Promise { const requestContext = this.requestFactory.logoutUser(options); // build promise chain @@ -412,7 +412,7 @@ export class UserApi { }); } - public updateUser(username: string, user: User, options?: any): Promise { + public updateUser(username: string, user: User, options?: Configuration): Promise { const requestContext = this.requestFactory.updateUser(username, user, options); // build promise chain diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index f1ef2d30044d..6e0c08a9baf6 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -7,8 +7,8 @@ export * from './User'; import { ApiResponse } from './ApiResponse'; import { Category } from './Category'; -import { Order } from './Order'; -import { Pet } from './Pet'; +import { Order , OrderStatusEnum } from './Order'; +import { Pet , PetStatusEnum } from './Pet'; import { Tag } from './Tag'; import { User } from './User'; @@ -24,10 +24,10 @@ let primitives = [ "any" ]; -let enumsMap: {[index: string]: any} = { - "Order.StatusEnum": Order.StatusEnum, - "Pet.StatusEnum": Pet.StatusEnum, -} +let enumsMap: Set = new Set([ + "OrderStatusEnum", + "PetStatusEnum", +]); let typeMap: {[index: string]: any} = { "ApiResponse": ApiResponse, @@ -47,7 +47,7 @@ export class ObjectSerializer { } else if (expectedType === "Date") { return expectedType; } else { - if (enumsMap[expectedType]) { + if (enumsMap.has(expectedType)) { return expectedType; } @@ -91,7 +91,7 @@ export class ObjectSerializer { } else if (type === "Date") { return data.toISOString(); } else { - if (enumsMap[type]) { + if (enumsMap.has(type)) { return data; } if (!typeMap[type]) { // in case we dont know the type @@ -131,7 +131,7 @@ export class ObjectSerializer { } else if (type === "Date") { return new Date(data); } else { - if (enumsMap[type]) {// is Enum + if (enumsMap.has(type)) {// is Enum return data; } diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index 8527b6f208f7..f08f21cf4b7b 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -13,7 +13,7 @@ export class Order { /** * Order Status */ - 'status'?: Order.StatusEnum; + 'status'?: OrderStatusEnum; 'complete'?: boolean; static discriminator: string | undefined = undefined; @@ -42,7 +42,7 @@ export class Order { { "name": "status", "baseName": "status", - "type": "Order.StatusEnum" + "type": "OrderStatusEnum" }, { "name": "complete", @@ -55,10 +55,6 @@ export class Order { } } -export namespace Order { - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } -} + +export type OrderStatusEnum = "placed" | "approved" | "delivered" ; + diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index cc4e4d7d1a30..a2b7d1691ec0 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -16,7 +16,7 @@ export class Pet { /** * pet status in the store */ - 'status'?: Pet.StatusEnum; + 'status'?: PetStatusEnum; static discriminator: string | undefined = undefined; @@ -49,7 +49,7 @@ export class Pet { { "name": "status", "baseName": "status", - "type": "Pet.StatusEnum" + "type": "PetStatusEnum" } ]; static getAttributeTypeMap() { @@ -57,10 +57,6 @@ export class Pet { } } -export namespace Pet { - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } -} + +export type PetStatusEnum = "available" | "pending" | "sold" ; + diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 012dabaf4ef7..53bdb215ea3c 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -13,7 +13,7 @@ const pet = new Pet() pet.id = Math.floor(Math.random() * 100000) pet.name = "PetName" pet.photoUrls = [] -pet.status = Pet.StatusEnum.Available +pet.status = 'available' pet.tags = [ tag ] pet.category = undefined diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index 342ea63b26c7..a6cb1bcc9945 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -48,7 +48,7 @@ describe("ObjectSerializer", () => { }); it ("Enum", () => { - const input = Pet.StatusEnum.Available + const input = "available" expect(ObjectSerializer.serialize(input, "Pet.StatusEnum")).to.equal("available") }) @@ -74,7 +74,7 @@ describe("ObjectSerializer", () => { pet.category = category pet.name = "PetName" pet.photoUrls = [ "url", "other url"] - pet.status = Pet.StatusEnum.Available + pet.status = "available" pet.tags = tags expect(ObjectSerializer.serialize(pet, "Pet")).to.deep.equal({ @@ -149,7 +149,7 @@ describe("ObjectSerializer", () => { }); it ("Enum", () => { - const input = Pet.StatusEnum.Available + const input = "available" expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum")).to.equal(input) }) @@ -175,7 +175,7 @@ describe("ObjectSerializer", () => { pet.category = category pet.name = "PetName" pet.photoUrls = [ "url", "other url"] - pet.status = Pet.StatusEnum.Available + pet.status = "available" pet.tags = tags const deserialized = ObjectSerializer.deserialize({ From 8068315f7920e72571b83fe56772c8c870002d7f Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 4 Mar 2019 00:13:59 +0100 Subject: [PATCH 32/85] Remove tab --- .../openapitools/codegen/languages/TypeScriptClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 4b0dcc7809c6..43dae3adec84 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -678,7 +678,7 @@ public String getTypeDeclaration(Schema p) { inner = (Schema) p.getAdditionalProperties(); return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; } else if (ModelUtils.isFileSchema(p)) { - // TODO: Change type declaration + // TODO: Change type declaration return "HttpFile"; } else if (ModelUtils.isBinarySchema(p)) { return "any"; From aeef285190b920ad90fb24278da7ed5a160043d0 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 4 Mar 2019 00:41:54 +0100 Subject: [PATCH 33/85] Restructured module layout --- .../generators/fetch/index.mustache | 26 ++++++++++++------ .../resources/typescript/http/http.mustache | 2 ++ .../typescript/builds/default/http/http.ts | 4 ++- .../typescript/builds/default/index.ts | 27 +++++++++++++------ .../petstore/typescript/tests/default/test.ts | 27 ------------------- .../tests/default/test/api/PetApi.test.ts | 19 ++++++------- .../tests/default/test/auth/auth.test.ts | 19 +++++++------ .../test/http/isomorphic-fetch.test.ts | 20 +++++++------- .../test/models/ObjectSerializer.test.ts | 24 ++++++++--------- 9 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 samples/client/petstore/typescript/tests/default/test.ts diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache index e7c7bd4e5a96..f244e4733a8c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache @@ -1,8 +1,18 @@ -export * from './http/http'; -export { IsomorphicFetchHttpLibrary } from './http/isomorphic-fetch'; -export * from './auth/auth'; -export * from './middleware'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file +import * as http from './http/http'; +import * as auth from './auth/auth'; +import {Middleware} from './middleware'; +import * as models from './models/all'; +import { Configuration} from './configuration' +import * as apis from './PromiseAPI'; +import * as exceptions from './apis/exception'; + +export { + http, + + auth, + Middleware, + models, + Configuration, + apis, + exceptions +}; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 8e11238e3c77..692cac751462 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -4,6 +4,8 @@ import * as FormData from "form-data"; // @ts-ignore import * as URLParse from "url-parse"; +export * from './isomorphic-fetch'; + export enum HttpMethod { GET = "GET", HEAD = "HEAD", diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 8e11238e3c77..34bffd7a8e40 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -4,6 +4,8 @@ import * as FormData from "form-data"; // @ts-ignore import * as URLParse from "url-parse"; +export * from './isomorphic-fetch'; + export enum HttpMethod { GET = "GET", HEAD = "HEAD", @@ -103,4 +105,4 @@ export class ResponseContext { export interface HttpLibrary { send(request: RequestContext): Promise; -} \ No newline at end of file +} diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index e7c7bd4e5a96..5de2901009a3 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,8 +1,19 @@ -export * from './http/http'; -export { IsomorphicFetchHttpLibrary } from './http/isomorphic-fetch'; -export * from './auth/auth'; -export * from './middleware'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file +import * as http from './http/http'; +import * as auth from './auth/auth'; +import {Middleware} from './middleware'; +import * as models from './models/all'; +import { Configuration} from './configuration' +import * as apis from './PromiseAPI'; +import * as exceptions from './apis/exception'; + + +export { + http, + + auth, + Middleware, + models, + Configuration, + apis, + exceptions +}; \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test.ts b/samples/client/petstore/typescript/tests/default/test.ts deleted file mode 100644 index 763d9ea8db0f..000000000000 --- a/samples/client/petstore/typescript/tests/default/test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import {PetApi, Configuration, Middleware, RequestContext, ResponseContext} from 'ts-petstore-client'; - -class MiddlewareA implements Middleware { - - public pre(request: RequestContext) { - console.log(request); - return Promise.resolve(request); - } - - public post(response: ResponseContext) { - console.log(response) - return Promise.resolve(response); - } -} - -const config = new Configuration({ - middleware: [ - new MiddlewareA() - ] -}); -const api = new PetApi(config); - -api.getPetById(3).then((pet) => { - console.log(pet) -}).catch((err) => { - console.log(err); -}); diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 53bdb215ea3c..98c478995cea 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -1,15 +1,16 @@ -import {PetApi, Configuration, Pet, ApiException, Tag, HttpFile} from 'ts-petstore-client' +import * as petstore from 'ts-petstore-client' + import { expect, assert } from "chai"; import * as fs from 'fs'; -const configuration = new Configuration() -const petApi = new PetApi(configuration) +const configuration = new petstore.Configuration() +const petApi = new petstore.apis.PetApi(configuration) -const tag = new Tag(); +const tag = new petstore.models.Tag(); tag.name = "tag1" tag.id = Math.floor(Math.random() * 100000) -const pet = new Pet() +const pet = new petstore.models.Pet() pet.id = Math.floor(Math.random() * 100000) pet.name = "PetName" pet.photoUrls = [] @@ -34,7 +35,7 @@ describe("PetApi", () =>{ return petApi.deletePet(pet.id) }).then(() => { return petApi.getPetById(pet.id) - }).then((pet: Pet) => { + }).then((pet: petstore.models.Pet) => { done("Pet with id " + pet.id + " was not deleted!"); }).catch((err: any) => { if (err.code && err.code == 404) { @@ -48,7 +49,7 @@ describe("PetApi", () =>{ it("findPetsByStatus", (done) => { petApi.addPet(pet).then(() => { return petApi.findPetsByStatus(["available"]) - }).then((pets: Pet[]) => { + }).then((pets: petstore.models.Pet[]) => { expect(pets.length).to.be.at.least(1); done(); }).catch((err) => { @@ -71,7 +72,7 @@ describe("PetApi", () =>{ it("getPetById", (done) => { petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((returnedPet: Pet) => { + }).then((returnedPet: petstore.models.Pet) => { expect(returnedPet).to.deep.equal(pet); done(); }).catch((err) => { @@ -92,7 +93,7 @@ describe("PetApi", () =>{ }); }).then(() => { return petApi.getPetById(pet.id); - }).then((returnedPet: Pet) => { + }).then((returnedPet: petstore.models.Pet) => { expect(returnedPet.id).to.equal(pet.id) expect(returnedPet.name).to.equal(updatedName); done(); diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts index 790d34caaa86..5993b7404397 100644 --- a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -1,5 +1,4 @@ -import {NoAuthentication, APIKeyAuthentication} from "ts-petstore-client"; -import {RequestContext, HttpMethod} from 'ts-petstore-client'; +import * as petstore from 'ts-petstore-client'; import { expect} from "chai"; @@ -7,8 +6,8 @@ import { expect} from "chai"; describe("Security Authentication", () => { describe("No Authentication", () => { it("No Authentication", () => { - let ctx = new RequestContext("http://google.com", HttpMethod.GET); - let noAuth = new NoAuthentication(); + let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); + let noAuth = new petstore.auth.NoAuthentication(); noAuth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); @@ -20,8 +19,8 @@ describe("Security Authentication", () => { describe("API Key Authentication", () => { // TODO: make all params const variables it("Header API Key", () => { - let ctx = new RequestContext("http://google.com", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); + let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); + let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); @@ -31,8 +30,8 @@ describe("Security Authentication", () => { }); it("Query API Key", () => { - let ctx = new RequestContext("http://google.com?a=b", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); + let ctx = new petstore.http.RequestContext("http://google.com?a=b", petstore.http.HttpMethod.GET); + let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.contain("paramName=apiKey"); @@ -41,8 +40,8 @@ describe("Security Authentication", () => { }); it("Cookie API Key", () => { - let ctx = new RequestContext("http://google.com", HttpMethod.GET); - let auth = new APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); + let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); + let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index 181477a408c4..3fa0113d37b9 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -1,9 +1,11 @@ -import {RequestContext, HttpMethod, ResponseContext, HttpLibrary, IsomorphicFetchHttpLibrary } from "ts-petstore-client"; +import * as petstore from "ts-petstore-client"; + + import { expect} from "chai"; import * as FormData from "form-data"; -let libs: { [key: string]: HttpLibrary } = { - "isomorphic-fetch": new IsomorphicFetchHttpLibrary() +let libs: { [key: string]: petstore.http.HttpLibrary } = { + "isomorphic-fetch": new petstore.http.IsomorphicFetchHttpLibrary() } @@ -12,10 +14,10 @@ for (let libName in libs) { describe("Isomorphic Fetch", () => { it("GET-Request", (done) => { - let requestContext = new RequestContext("http://httpbin.org/get", HttpMethod.GET); + let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then((resp: ResponseContext) => { + lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["headers"]).to.exist; @@ -28,7 +30,7 @@ for (let libName in libs) { }) it("POST-Request", (done) => { - let requestContext = new RequestContext("http://httpbin.org/post", HttpMethod.POST); + let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); let formData: FormData = new FormData() @@ -36,7 +38,7 @@ for (let libName in libs) { formData.append("testFile", Buffer.from("abc"), "fileName.json"); requestContext.setBody(formData); - lib.send(requestContext).then((resp: ResponseContext) => { + lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["headers"]).to.exist; @@ -51,10 +53,10 @@ for (let libName in libs) { }); it("Cookies-Request", (done) => { - let requestContext = new RequestContext("http://httpbin.org/cookies", HttpMethod.GET); + let requestContext = new petstore.http.RequestContext("http://httpbin.org/cookies", petstore.http.HttpMethod.GET); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then((resp: ResponseContext) => { + lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index a6cb1bcc9945..d35020f32096 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -1,6 +1,6 @@ const rewire = require("rewire") import { expect} from "chai"; -import {Pet, Category, Tag} from "ts-petstore-client" +import * as petstore from "ts-petstore-client" const objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts") @@ -41,7 +41,7 @@ describe("ObjectSerializer", () => { }) it("Class", () => { - const input = new Category() + const input = new petstore.models.Category() input.id = 4 input.name = "Test" expect(ObjectSerializer.serialize(input, "Category")).to.deep.equal({ "id": input.id, "name": input.name}) @@ -56,7 +56,7 @@ describe("ObjectSerializer", () => { const tags = [] const tagResult = [] for (let i = 0; i < 2; i++) { - const tag = new Tag() + const tag = new petstore.models.Tag() tag.id = i tag.name = "Tag" + i tags.push(tag) @@ -66,10 +66,10 @@ describe("ObjectSerializer", () => { }) } - const category = new Category() + const category = new petstore.models.Category() category.id = 4 category.name = "TestCat" - const pet = new Pet() + const pet = new petstore.models.Pet() pet.id = 145 pet.category = category pet.name = "PetName" @@ -93,7 +93,7 @@ describe("ObjectSerializer", () => { const categories = [] const result = [] for (let i = 0; i < 2; i++) { - const category = new Category() + const category = new petstore.models.Category() category.id = i category.name = "Cat" + i categories.push(category) @@ -139,7 +139,7 @@ describe("ObjectSerializer", () => { }) it("Class", () => { - const input = new Category() + const input = new petstore.models.Category() input.id = 4 input.name = "Test" const deserialized = ObjectSerializer.deserialize({ "id": 4, "name": "Test"}, "Category") @@ -157,7 +157,7 @@ describe("ObjectSerializer", () => { const tags = [] const tagResult = [] for (let i = 0; i < 2; i++) { - const tag = new Tag() + const tag = new petstore.models.Tag() tag.id = i tag.name = "Tag" + i tags.push(tag) @@ -167,10 +167,10 @@ describe("ObjectSerializer", () => { }) } - const category = new Category() + const category = new petstore.models.Category() category.id = 4 category.name = "TestCat" - const pet = new Pet() + const pet = new petstore.models.Pet() pet.id = 145 pet.category = category pet.name = "PetName" @@ -188,7 +188,7 @@ describe("ObjectSerializer", () => { "photoUrls": [ "url", "other url"], "status": "available", "tags": tagResult - }, "Pet") as Pet + }, "Pet") as petstore.models.Pet expect(deserialized.constructor.name).to.equal("Pet") expect(deserialized.category.constructor.name).to.equal("Category") @@ -202,7 +202,7 @@ describe("ObjectSerializer", () => { const categories = [] const result = [] for (let i = 0; i < 2; i++) { - const category = new Category() + const category = new petstore.models.Category() category.id = i category.name = "Cat" + i categories.push(category) From 1d27563a4109f23ba35dd80046a68bcc5a3a52c8 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 14:11:39 +0100 Subject: [PATCH 34/85] Use observables internally --- .../languages/TypeScriptClientCodegen.java | 7 +- .../typescript/api/middleware.mustache | 5 +- .../typescript/generators/PromiseAPI.mustache | 52 --- .../{fetch/index.mustache => fetch.mustache} | 2 +- .../generators/types/ObservableAPI.mustache | 54 +++ .../generators/types/PromiseAPI.mustache | 38 ++ .../resources/typescript/http/http.mustache | 4 +- .../typescript/http/isomorphic-fetch.mustache | 7 +- .../resources/typescript/package.mustache | 4 +- .../typescript/builds/default/PromiseAPI.ts | 364 ++++++++------- .../typescript/builds/default/http/http.ts | 6 +- .../builds/default/http/isomorphic-fetch.ts | 7 +- .../typescript/builds/default/index.ts | 3 +- .../typescript/builds/default/middleware.ts | 5 +- .../builds/default/package-lock.json | 126 +++++ .../typescript/builds/default/package.json | 4 +- .../builds/default/types/ObservableAPI.ts | 440 ++++++++++++++++++ .../builds/default/types/PromiseAPI.ts | 158 +++++++ .../tests/default/package-lock.json | 249 +++++++++- .../typescript/tests/default/package.json | 2 + .../tests/default/test/api/PetApi.test.ts | 4 +- .../test/http/isomorphic-fetch.test.ts | 67 +-- 22 files changed, 1322 insertions(+), 286 deletions(-) delete mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache rename modules/openapi-generator/src/main/resources/typescript/generators/{fetch/index.mustache => fetch.mustache} (88%) create mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache create mode 100644 samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts create mode 100644 samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 43dae3adec84..3c69beb3f238 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -136,8 +136,11 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("model/models_all.mustache", "models", "all.ts")); // TODO: add supporting files depending on cli parameter e.g. fetch vs angular - supportingFiles.add(new SupportingFile("generators/PromiseAPI.mustache", "PromiseAPI.ts")); - supportingFiles.add(new SupportingFile("generators/fetch/index.mustache", "index.ts")); + supportingFiles.add(new SupportingFile("generators/types/PromiseAPI.mustache", "types", "PromiseAPI.ts")); + supportingFiles.add(new SupportingFile("generators/types/ObservableAPI.mustache", "types", "ObservableAPI.ts")); + + + supportingFiles.add(new SupportingFile("generators/fetch.mustache", "index.ts")); // models // TODO: properly set model and api packages diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index bb2037740f24..5e6d88eeeb1d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -1,6 +1,7 @@ import {RequestContext, ResponseContext} from './http/http'; +import { Observable } from 'rxjs'; export interface Middleware { - pre(context: RequestContext): Promise; - post(context: ResponseContext): Promise; + pre(context: RequestContext): Observable; + post(context: ResponseContext): Observable; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache deleted file mode 100644 index e60ef05dd76f..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/generators/PromiseAPI.mustache +++ /dev/null @@ -1,52 +0,0 @@ -import { ResponseContext, HttpFile } from './http/http'; -import * as models from './models/all'; -import { Configuration} from './configuration' - -{{#models}} -{{#model}} -import { {{name}} } from './models/{{name}}'; -{{/model}} -{{/models}} -{{#apiInfo}} -{{#apis}} - -{{#operations}} -import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "./apis/{{classname}}"; -export class {{classname}} { - private requestFactory: {{classname}}RequestFactory; - private responseProcessor: {{classname}}ResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new {{classname}}RequestFactory(configuration); - this.responseProcessor = new {{classname}}ResponseProcessor(); - } - -{{#operation}} - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { - const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - - // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); - } - - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); - for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); - } - return middlewarePostPromise.then((rsp) => this.responseProcessor.{{nickname}}(rsp)); - }); - } - -{{/operation}} - -} - -{{/operations}} - - -{{/apis}} -{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache similarity index 88% rename from modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache rename to modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache index f244e4733a8c..e17b67f2a6c7 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache @@ -3,7 +3,7 @@ import * as auth from './auth/auth'; import {Middleware} from './middleware'; import * as models from './models/all'; import { Configuration} from './configuration' -import * as apis from './PromiseAPI'; +import * as apis from './types/PromiseAPI'; import * as exceptions from './apis/exception'; export { diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache new file mode 100644 index 000000000000..a8e02e4ba949 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache @@ -0,0 +1,54 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of } from 'rxjs'; +import {mergeMap, map} from 'rxjs/operators'; + +{{#models}} +{{#model}} +import { {{name}} } from '../models/{{name}}'; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} + +{{#operations}} +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; +export class Observable{{classname}} { + private requestFactory: {{classname}}RequestFactory; + private responseProcessor: {{classname}}ResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new {{classname}}RequestFactory(configuration); + this.responseProcessor = new {{classname}}ResponseProcessor(); + } + +{{#operation}} + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.{{nickname}}(rsp))); + })); + } + +{{/operation}} + +} + +{{/operations}} + + +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache new file mode 100644 index 000000000000..4f1ea13cdef0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache @@ -0,0 +1,38 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +{{#models}} +{{#model}} +import { {{name}} } from '../models/{{name}}'; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} +import { Observable{{classname}} } from './ObservableAPI'; + + +{{#operations}} +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; +export class Promise{{classname}} { + private api: Observable{{classname}} + + public constructor(configuration: Configuration) { + this.api = new Observable{{classname}}(configuration); + } + +{{#operation}} + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + const result = this.api.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + return result.toPromise(); + } + +{{/operation}} + +} + +{{/operations}} + + +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 692cac751462..5bd5f8229ed5 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -3,6 +3,8 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; +import { Observable } from 'rxjs'; + export * from './isomorphic-fetch'; @@ -104,5 +106,5 @@ export class ResponseContext { } export interface HttpLibrary { - send(request: RequestContext): Promise; + send(request: RequestContext): Observable; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index b62f68418d35..e6b5b183e679 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,15 +1,16 @@ import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' +import { from, Observable } from 'rxjs'; e6p.polyfill(); import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { - public send(request: RequestContext): Promise { + public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - return fetch(request.getUrl(), { + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), @@ -25,6 +26,8 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { return new ResponseContext(resp.status, headers, body) }); }); + + return from(resultPromise); } } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 000086e2010f..087e657262df 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -24,7 +24,9 @@ "@types/isomorphic-fetch": "0.0.34", "form-data": "^2.3.2", "@types/form-data": "^2.2.1", - "url-parse": "^1.4.3" + "url-parse": "^1.4.3", + "rxjs": "^6.4.0", + "@types/rx": "^4.1.1" }, "devDependencies": { "typescript": "^2.9.2" diff --git a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts index 48f63d417e67..9306e5f30f72 100644 --- a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts @@ -1,6 +1,8 @@ -import { ResponseContext, HttpFile } from './http/http'; +import { ResponseContext, RequestContext, HttpFile } from './http/http'; import * as models from './models/all'; import { Configuration} from './configuration' +import { Observable, of } from 'rxjs'; +import {mergeMap, map} from 'rxjs/operators'; import { ApiResponse } from './models/ApiResponse'; import { Category } from './models/Category'; @@ -19,156 +21,156 @@ export class PetApi { this.responseProcessor = new PetApiResponseProcessor(); } - public addPet(pet: Pet, options?: Configuration): Promise { + public addPet(pet: Pet, options?: Configuration): Observable { const requestContext = this.requestFactory.addPet(pet, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.addPet(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); + })); } - public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deletePet(petId, apiKey, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.deletePet(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); + })); } - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { const requestContext = this.requestFactory.findPetsByStatus(status, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.findPetsByStatus(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); + })); } - public findPetsByTags(tags: Array, options?: Configuration): Promise> { + public findPetsByTags(tags: Array, options?: Configuration): Observable> { const requestContext = this.requestFactory.findPetsByTags(tags, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.findPetsByTags(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); + })); } - public getPetById(petId: number, options?: Configuration): Promise { + public getPetById(petId: number, options?: Configuration): Observable { const requestContext = this.requestFactory.getPetById(petId, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.getPetById(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); + })); } - public updatePet(pet: Pet, options?: Configuration): Promise { + public updatePet(pet: Pet, options?: Configuration): Observable { const requestContext = this.requestFactory.updatePet(pet, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.updatePet(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); + })); } - public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { + public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable { const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.updatePetWithForm(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); + })); } - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.uploadFile(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); + })); } @@ -187,80 +189,80 @@ export class StoreApi { this.responseProcessor = new StoreApiResponseProcessor(); } - public deleteOrder(orderId: string, options?: Configuration): Promise { + public deleteOrder(orderId: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deleteOrder(orderId, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.deleteOrder(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); + })); } - public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { + public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { const requestContext = this.requestFactory.getInventory(options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.getInventory(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); + })); } - public getOrderById(orderId: number, options?: Configuration): Promise { + public getOrderById(orderId: number, options?: Configuration): Observable { const requestContext = this.requestFactory.getOrderById(orderId, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.getOrderById(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); + })); } - public placeOrder(order: Order, options?: Configuration): Promise { + public placeOrder(order: Order, options?: Configuration): Observable { const requestContext = this.requestFactory.placeOrder(order, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.placeOrder(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); + })); } @@ -279,156 +281,156 @@ export class UserApi { this.responseProcessor = new UserApiResponseProcessor(); } - public createUser(user: User, options?: Configuration): Promise { + public createUser(user: User, options?: Configuration): Observable { const requestContext = this.requestFactory.createUser(user, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.createUser(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); + })); } - public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.createUsersWithArrayInput(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); + })); } - public createUsersWithListInput(user: Array, options?: Configuration): Promise { + public createUsersWithListInput(user: Array, options?: Configuration): Observable { const requestContext = this.requestFactory.createUsersWithListInput(user, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.createUsersWithListInput(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); + })); } - public deleteUser(username: string, options?: Configuration): Promise { + public deleteUser(username: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deleteUser(username, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.deleteUser(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); + })); } - public getUserByName(username: string, options?: Configuration): Promise { + public getUserByName(username: string, options?: Configuration): Observable { const requestContext = this.requestFactory.getUserByName(username, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.getUserByName(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); + })); } - public loginUser(username: string, password: string, options?: Configuration): Promise { + public loginUser(username: string, password: string, options?: Configuration): Observable { const requestContext = this.requestFactory.loginUser(username, password, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.loginUser(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); + })); } - public logoutUser(options?: Configuration): Promise { + public logoutUser(options?: Configuration): Observable { const requestContext = this.requestFactory.logoutUser(options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.logoutUser(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); + })); } - public updateUser(username: string, user: User, options?: Configuration): Promise { + public updateUser(username: string, user: User, options?: Configuration): Observable { const requestContext = this.requestFactory.updateUser(username, user, options); // build promise chain - let middlewarePrePromise = Promise.resolve(requestContext); + let middlewarePreObservable = of(requestContext); for (let middleware of this.configuration.middleware) { - middlewarePrePromise = middlewarePrePromise.then((ctx) => middleware.pre(ctx)); + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } - return middlewarePrePromise.then((ctx) => this.configuration.httpApi.send(ctx)). - then((response: ResponseContext) => { - let middlewarePostPromise = Promise.resolve(response); + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); for (let middleware of this.configuration.middleware) { - middlewarePostPromise = middlewarePostPromise.then((rsp) => middleware.post(rsp)); + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); } - return middlewarePostPromise.then((rsp) => this.responseProcessor.updateUser(rsp)); - }); + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); + })); } diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 34bffd7a8e40..5bd5f8229ed5 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -3,6 +3,8 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; +import { Observable } from 'rxjs'; + export * from './isomorphic-fetch'; @@ -104,5 +106,5 @@ export class ResponseContext { } export interface HttpLibrary { - send(request: RequestContext): Promise; -} + send(request: RequestContext): Observable; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index b62f68418d35..e6b5b183e679 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -1,15 +1,16 @@ import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' +import { from, Observable } from 'rxjs'; e6p.polyfill(); import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { - public send(request: RequestContext): Promise { + public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - return fetch(request.getUrl(), { + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), @@ -25,6 +26,8 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { return new ResponseContext(resp.status, headers, body) }); }); + + return from(resultPromise); } } diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index 5de2901009a3..e17b67f2a6c7 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -3,10 +3,9 @@ import * as auth from './auth/auth'; import {Middleware} from './middleware'; import * as models from './models/all'; import { Configuration} from './configuration' -import * as apis from './PromiseAPI'; +import * as apis from './types/PromiseAPI'; import * as exceptions from './apis/exception'; - export { http, diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index bb2037740f24..5e6d88eeeb1d 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -1,6 +1,7 @@ import {RequestContext, ResponseContext} from './http/http'; +import { Observable } from 'rxjs'; export interface Middleware { - pre(context: RequestContext): Promise; - post(context: ResponseContext): Promise; + pre(context: RequestContext): Observable; + post(context: ResponseContext): Observable; } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index 331f3c78d71d..3420dfb5cb3c 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -22,6 +22,119 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" }, + "@types/rx": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "requires": { + "@types/rx-lite": "*" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -122,11 +235,24 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, + "rxjs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", + "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "requires": { + "tslib": "^1.9.0" + } + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index 7ffb1436e084..01d8c238d6db 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -24,7 +24,9 @@ "@types/isomorphic-fetch": "0.0.34", "form-data": "^2.3.2", "@types/form-data": "^2.2.1", - "url-parse": "^1.4.3" + "url-parse": "^1.4.3", + "rxjs": "^6.4.0", + "@types/rx": "^4.1.1" }, "devDependencies": { "typescript": "^2.9.2" diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts new file mode 100644 index 000000000000..8499e8bacad4 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -0,0 +1,440 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of } from 'rxjs'; +import {mergeMap, map} from 'rxjs/operators'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class ObservablePetApi { + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new PetApiRequestFactory(configuration); + this.responseProcessor = new PetApiResponseProcessor(); + } + + public addPet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.addPet(pet, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); + })); + } + + public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deletePet(petId, apiKey, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); + })); + } + + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { + const requestContext = this.requestFactory.findPetsByStatus(status, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); + })); + } + + public findPetsByTags(tags: Array, options?: Configuration): Observable> { + const requestContext = this.requestFactory.findPetsByTags(tags, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); + })); + } + + public getPetById(petId: number, options?: Configuration): Observable { + const requestContext = this.requestFactory.getPetById(petId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); + })); + } + + public updatePet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePet(pet, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); + })); + } + + public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); + })); + } + + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { + const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); + })); + } + + +} + + + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class ObservableStoreApi { + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new StoreApiRequestFactory(configuration); + this.responseProcessor = new StoreApiResponseProcessor(); + } + + public deleteOrder(orderId: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deleteOrder(orderId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); + })); + } + + public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { + const requestContext = this.requestFactory.getInventory(options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); + })); + } + + public getOrderById(orderId: number, options?: Configuration): Observable { + const requestContext = this.requestFactory.getOrderById(orderId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); + })); + } + + public placeOrder(order: Order, options?: Configuration): Observable { + const requestContext = this.requestFactory.placeOrder(order, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); + })); + } + + +} + + + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class ObservableUserApi { + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; + + public constructor(private configuration: Configuration) { + this.requestFactory = new UserApiRequestFactory(configuration); + this.responseProcessor = new UserApiResponseProcessor(); + } + + public createUser(user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUser(user, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); + })); + } + + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); + })); + } + + public createUsersWithListInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithListInput(user, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); + })); + } + + public deleteUser(username: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deleteUser(username, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); + })); + } + + public getUserByName(username: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.getUserByName(username, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); + })); + } + + public loginUser(username: string, password: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.loginUser(username, password, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); + })); + } + + public logoutUser(options?: Configuration): Observable { + const requestContext = this.requestFactory.logoutUser(options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); + })); + } + + public updateUser(username: string, user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.updateUser(username, user, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); + })); + } + + +} + + + diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts new file mode 100644 index 000000000000..c449b9e5b8ea --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -0,0 +1,158 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; +import { ObservablePetApi } from './ObservableAPI'; + + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class PromisePetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration) { + this.api = new ObservablePetApi(configuration); + } + + public addPet(pet: Pet, options?: Configuration): Promise { + const result = this.api.addPet(pet, options); + return result.toPromise(); + } + + public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + const result = this.api.deletePet(petId, apiKey, options); + return result.toPromise(); + } + + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { + const result = this.api.findPetsByStatus(status, options); + return result.toPromise(); + } + + public findPetsByTags(tags: Array, options?: Configuration): Promise> { + const result = this.api.findPetsByTags(tags, options); + return result.toPromise(); + } + + public getPetById(petId: number, options?: Configuration): Promise { + const result = this.api.getPetById(petId, options); + return result.toPromise(); + } + + public updatePet(pet: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(pet, options); + return result.toPromise(); + } + + public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { + const result = this.api.updatePetWithForm(petId, name, status, options); + return result.toPromise(); + } + + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + const result = this.api.uploadFile(petId, additionalMetadata, file, options); + return result.toPromise(); + } + + +} + + + +import { ObservableStoreApi } from './ObservableAPI'; + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class PromiseStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration) { + this.api = new ObservableStoreApi(configuration); + } + + public deleteOrder(orderId: string, options?: Configuration): Promise { + const result = this.api.deleteOrder(orderId, options); + return result.toPromise(); + } + + public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { + const result = this.api.getInventory(options); + return result.toPromise(); + } + + public getOrderById(orderId: number, options?: Configuration): Promise { + const result = this.api.getOrderById(orderId, options); + return result.toPromise(); + } + + public placeOrder(order: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(order, options); + return result.toPromise(); + } + + +} + + + +import { ObservableUserApi } from './ObservableAPI'; + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class PromiseUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration) { + this.api = new ObservableUserApi(configuration); + } + + public createUser(user: User, options?: Configuration): Promise { + const result = this.api.createUser(user, options); + return result.toPromise(); + } + + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(user, options); + return result.toPromise(); + } + + public createUsersWithListInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(user, options); + return result.toPromise(); + } + + public deleteUser(username: string, options?: Configuration): Promise { + const result = this.api.deleteUser(username, options); + return result.toPromise(); + } + + public getUserByName(username: string, options?: Configuration): Promise { + const result = this.api.getUserByName(username, options); + return result.toPromise(); + } + + public loginUser(username: string, password: string, options?: Configuration): Promise { + const result = this.api.loginUser(username, password, options); + return result.toPromise(); + } + + public logoutUser(options?: Configuration): Promise { + const result = this.api.logoutUser(options); + return result.toPromise(); + } + + public updateUser(username: string, user: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, user, options); + return result.toPromise(); + } + + +} + + + diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index de0cb9aad919..609eb4d29091 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -48,6 +48,119 @@ "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" }, + "@types/rx": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "requires": { + "@types/rx-lite": "*" + } + }, "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", @@ -1052,6 +1165,14 @@ "rx-lite": "*" } }, + "rxjs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", + "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -1232,10 +1353,12 @@ "requires": { "@types/form-data": "^2.2.1", "@types/isomorphic-fetch": "0.0.34", + "@types/rx": "^4.1.1", "btoa": "^1.2.1", "es6-promise": "^4.2.4", "form-data": "^2.3.2", "isomorphic-fetch": "^2.2.1", + "rxjs": "^6.4.0", "url-parse": "^1.4.3" }, "dependencies": { @@ -1254,6 +1377,106 @@ "version": "10.12.0", "bundled": true }, + "@types/rx": { + "version": "4.1.1", + "bundled": true, + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "bundled": true + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "bundled": true, + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "bundled": true, + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, "asynckit": { "version": "0.4.0", "bundled": true @@ -1313,14 +1536,14 @@ } }, "mime-db": { - "version": "1.37.0", + "version": "1.36.0", "bundled": true }, "mime-types": { - "version": "2.1.21", + "version": "2.1.20", "bundled": true, "requires": { - "mime-db": "~1.37.0" + "mime-db": "~1.36.0" } }, "node-fetch": { @@ -1339,10 +1562,25 @@ "version": "1.0.0", "bundled": true }, + "rxjs": { + "version": "6.4.0", + "bundled": true, + "requires": { + "tslib": "^1.9.0" + } + }, "safer-buffer": { "version": "2.1.2", "bundled": true }, + "tslib": { + "version": "1.9.3", + "bundled": true + }, + "typescript": { + "version": "2.9.2", + "bundled": true + }, "url-parse": { "version": "1.4.3", "bundled": true, @@ -1366,6 +1604,11 @@ "strip-json-comments": "^2.0.0" } }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", diff --git a/samples/client/petstore/typescript/tests/default/package.json b/samples/client/petstore/typescript/tests/default/package.json index 1f924a40bf3b..d88b1e07f9fc 100644 --- a/samples/client/petstore/typescript/tests/default/package.json +++ b/samples/client/petstore/typescript/tests/default/package.json @@ -3,8 +3,10 @@ "dependencies": { "@types/form-data": "^2.2.1", "@types/rewire": "^2.5.28", + "@types/rx": "^4.1.1", "form-data": "^2.3.2", "rewire": "^4.0.1", + "rxjs": "^6.4.0", "ts-node": "^3.3.0", "ts-petstore-client": "file:../../builds/default" }, diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 98c478995cea..813e5321eaa1 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -4,7 +4,7 @@ import { expect, assert } from "chai"; import * as fs from 'fs'; const configuration = new petstore.Configuration() -const petApi = new petstore.apis.PetApi(configuration) +const petApi = new petstore.apis.PromisePetApi(configuration) const tag = new petstore.models.Tag(); tag.name = "tag1" @@ -22,7 +22,7 @@ describe("PetApi", () =>{ it("addPet", (done) => { petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((createdPet) => { + }).then((createdPet: petstore.models.Pet) => { expect(createdPet).to.deep.equal(pet); done() }).catch((err) => { diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index 3fa0113d37b9..df08272870f4 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -1,5 +1,6 @@ import * as petstore from "ts-petstore-client"; +import {map} from 'rxjs/operators'; import { expect} from "chai"; import * as FormData from "form-data"; @@ -17,16 +18,18 @@ for (let libName in libs) { let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { - expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); - expect(body["headers"]).to.exist; - expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - done(); - }).catch((e) => { - done(e); - }) + lib.send(requestContext).subscribe((resp: petstore.http.ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["headers"]).to.exist; + expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + done(); + }, + (e: any) => { + done(e); + } + ) }) it("POST-Request", (done) => { @@ -38,32 +41,36 @@ for (let libName in libs) { formData.append("testFile", Buffer.from("abc"), "fileName.json"); requestContext.setBody(formData); - lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { - expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); - expect(body["headers"]).to.exist; - expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - expect(body["files"]["testFile"]).to.equal("abc"); - expect(body["form"]["test"]).to.equal("test2"); - done(); - }).catch((e) => { - done(e); - }) + lib.send(requestContext).subscribe( + (resp: petstore.http.ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["headers"]).to.exist; + expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); + expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); + expect(body["files"]["testFile"]).to.equal("abc"); + expect(body["form"]["test"]).to.equal("test2"); + done(); + }, + (e: any) => { + done(e); + }) }); it("Cookies-Request", (done) => { let requestContext = new petstore.http.RequestContext("http://httpbin.org/cookies", petstore.http.HttpMethod.GET); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then((resp: petstore.http.ResponseContext) => { - expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); - expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); - done(); - }).catch((e) => { - done(e); - }) + lib.send(requestContext).subscribe( + (resp: petstore.http.ResponseContext) => { + expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); + let body = JSON.parse(resp.body); + expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); + done(); + }, + (e: any) => { + done(e); + }) }) }) } \ No newline at end of file From df970ae8b1cf5df42b795165ed0826cd51a90e9d Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 14:35:46 +0100 Subject: [PATCH 35/85] Added promise based middleware --- .../typescript/api/middleware.mustache | 23 ++++++++++++++++++- .../typescript/configuration.mustache | 6 ++++- .../typescript/generators/fetch.mustache | 5 ++-- .../builds/default/configuration.ts | 6 ++++- .../typescript/builds/default/index.ts | 5 ++-- .../typescript/builds/default/middleware.ts | 23 ++++++++++++++++++- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index 5e6d88eeeb1d..89a895a32b4b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -1,7 +1,28 @@ import {RequestContext, ResponseContext} from './http/http'; -import { Observable } from 'rxjs'; +import { Observable, from } from 'rxjs'; export interface Middleware { pre(context: RequestContext): Observable; post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +export interface PromiseMiddleware { + pre(context: RequestContext): Observable; + post(context: ResponseContext): Observable; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 41d7a075f517..c31ae8fb359f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,5 +1,5 @@ import {HttpLibrary} from './http/http'; -import {Middleware} from './middleware'; +import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; @@ -9,6 +9,7 @@ export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests + promiseMiddleware?: PromiseMiddleware[]; authMethods?: AuthMethodsConfiguration } @@ -24,5 +25,8 @@ export class Configuration { this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); + } } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache index e17b67f2a6c7..ca1c5ff976ff 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache @@ -1,6 +1,6 @@ import * as http from './http/http'; import * as auth from './auth/auth'; -import {Middleware} from './middleware'; +import {Middleware, PromiseMiddleware} from './middleware'; import * as models from './models/all'; import { Configuration} from './configuration' import * as apis from './types/PromiseAPI'; @@ -10,7 +10,8 @@ export { http, auth, - Middleware, + Middleware, + PromiseMiddleware, models, Configuration, apis, diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index 41d7a075f517..c31ae8fb359f 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -1,5 +1,5 @@ import {HttpLibrary} from './http/http'; -import {Middleware} from './middleware'; +import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; @@ -9,6 +9,7 @@ export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests + promiseMiddleware?: PromiseMiddleware[]; authMethods?: AuthMethodsConfiguration } @@ -24,5 +25,8 @@ export class Configuration { this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); + } } } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index e17b67f2a6c7..ca1c5ff976ff 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,6 +1,6 @@ import * as http from './http/http'; import * as auth from './auth/auth'; -import {Middleware} from './middleware'; +import {Middleware, PromiseMiddleware} from './middleware'; import * as models from './models/all'; import { Configuration} from './configuration' import * as apis from './types/PromiseAPI'; @@ -10,7 +10,8 @@ export { http, auth, - Middleware, + Middleware, + PromiseMiddleware, models, Configuration, apis, diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index 5e6d88eeeb1d..89a895a32b4b 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -1,7 +1,28 @@ import {RequestContext, ResponseContext} from './http/http'; -import { Observable } from 'rxjs'; +import { Observable, from } from 'rxjs'; export interface Middleware { pre(context: RequestContext): Observable; post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +export interface PromiseMiddleware { + pre(context: RequestContext): Observable; + post(context: ResponseContext): Observable; } \ No newline at end of file From 861f774c56da60e19e61a409866ddf843913b1dd Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 14:47:00 +0100 Subject: [PATCH 36/85] Made discriminator and attributeTypeMap readonly --- .../src/main/resources/typescript/model/model.mustache | 6 +++--- .../typescript/builds/default/models/ApiResponse.ts | 4 ++-- .../petstore/typescript/builds/default/models/Category.ts | 4 ++-- .../petstore/typescript/builds/default/models/Order.ts | 4 ++-- .../client/petstore/typescript/builds/default/models/Pet.ts | 4 ++-- .../client/petstore/typescript/builds/default/models/Tag.ts | 4 ++-- .../petstore/typescript/builds/default/models/User.ts | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index b94d89990f97..ff2622c563de 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -21,14 +21,14 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/vars}} {{#discriminator}} - static discriminator: string | undefined = "{{discriminatorName}}"; + static readonly discriminator: string | undefined = "{{discriminatorName}}"; {{/discriminator}} {{^discriminator}} - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; {{/discriminator}} {{^isArrayModel}} - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ {{#vars}} { "name": "{{name}}", diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index 2624f2e5065f..f8f40e521549 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -10,9 +10,9 @@ export class ApiResponse { 'type'?: string; 'message'?: string; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "code", "baseName": "code", diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index f16c4fb2ea7e..3520fde26a5f 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -9,9 +9,9 @@ export class Category { 'id'?: number; 'name'?: string; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index f08f21cf4b7b..049cb8c7140c 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -16,9 +16,9 @@ export class Order { 'status'?: OrderStatusEnum; 'complete'?: boolean; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index a2b7d1691ec0..6dc00c53671f 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -18,9 +18,9 @@ export class Pet { */ 'status'?: PetStatusEnum; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index e1434bd3d136..1d11453712e8 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -9,9 +9,9 @@ export class Tag { 'id'?: number; 'name'?: string; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index 15df044dbf8c..d9510f87ca9a 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -18,9 +18,9 @@ export class User { */ 'userStatus'?: number; - static discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; - static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", From c8c58b4f5e1b3812b8521d783d1c9b629387169e Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 15:58:03 +0100 Subject: [PATCH 37/85] Configure discriminator correctly --- .../resources/typescript/model/model.mustache | 16 ++++++++- .../builds/default/models/ApiResponse.ts | 5 ++- .../typescript/builds/default/models/Cat.ts | 36 +++++++++++++++++++ .../builds/default/models/Category.ts | 5 ++- .../typescript/builds/default/models/Dog.ts | 33 +++++++++++++++++ .../builds/default/models/ErrorModel.ts | 30 ++++++++++++++++ .../default/models/ExtendedErrorModel.ts | 26 ++++++++++++++ .../builds/default/models/ObjectSerializer.ts | 16 +++++++++ .../typescript/builds/default/models/Order.ts | 5 ++- .../typescript/builds/default/models/Pet.ts | 5 ++- .../typescript/builds/default/models/Pet2.ts | 31 ++++++++++++++++ .../typescript/builds/default/models/Tag.ts | 5 ++- .../typescript/builds/default/models/User.ts | 5 ++- .../typescript/builds/default/models/all.ts | 5 +++ .../builds/default/types/ObservableAPI.ts | 5 +++ .../builds/default/types/PromiseAPI.ts | 5 +++ 16 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 samples/client/petstore/typescript/builds/default/models/Cat.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Dog.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/ErrorModel.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/Pet2.ts diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index ff2622c563de..78eae0ec438b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -28,7 +28,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/discriminator}} {{^isArrayModel}} - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ {{#vars}} { "name": "{{name}}", @@ -48,6 +48,20 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/parent}} } {{/isArrayModel}} + + public constructor() { + {{#parent}} + super(); + {{/parent}} + {{#allVars}} + {{#discriminatorValue}} + this.{{name}} = "{{discriminatorValue}}"; + {{/discriminatorValue}} + {{/allVars}} + {{#discriminatorName}} + this.{{discriminatorName}} = "{{classname}}"; + {{/discriminatorName}} + } } {{#hasEnums}} diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index f8f40e521549..cc919118ae77 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -12,7 +12,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "code", "baseName": "code", @@ -32,5 +32,8 @@ export class ApiResponse { static getAttributeTypeMap() { return ApiResponse.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Cat.ts b/samples/client/petstore/typescript/builds/default/models/Cat.ts new file mode 100644 index 000000000000..7474d1a8ad6d --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Cat.ts @@ -0,0 +1,36 @@ +/* + TODO: LICENSE INFO +*/ +import { Pet2 } from './Pet2'; + +/** +* A representation of a cat +*/ +export class Cat extends Pet2 { + /** + * The measured skill for hunting + */ + 'huntingSkill': CatHuntingSkillEnum; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "huntingSkill", + "baseName": "huntingSkill", + "type": "CatHuntingSkillEnum" + } ]; + + static getAttributeTypeMap() { + return super.getAttributeTypeMap().concat(Cat.attributeTypeMap); + } + + public constructor() { + super(); + this.petType = "Cat"; + } +} + + +export type CatHuntingSkillEnum = "clueless" | "lazy" | "adventurous" | "aggressive" ; + diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index 3520fde26a5f..af9bdf34d545 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -11,7 +11,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", @@ -26,5 +26,8 @@ export class Category { static getAttributeTypeMap() { return Category.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Dog.ts b/samples/client/petstore/typescript/builds/default/models/Dog.ts new file mode 100644 index 000000000000..27db62144300 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Dog.ts @@ -0,0 +1,33 @@ +/* + TODO: LICENSE INFO +*/ +import { Pet2 } from './Pet2'; + +/** +* A representation of a dog +*/ +export class Dog extends Pet2 { + /** + * the size of the pack the dog is from + */ + 'packSize': number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "packSize", + "baseName": "packSize", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return super.getAttributeTypeMap().concat(Dog.attributeTypeMap); + } + + public constructor() { + super(); + this.petType = "Dog"; + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts b/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts new file mode 100644 index 000000000000..9dc7a6e1ae45 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts @@ -0,0 +1,30 @@ +/* + TODO: LICENSE INFO +*/ + +export class ErrorModel { + 'message': string; + 'code': number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "message", + "baseName": "message", + "type": "string" + }, + { + "name": "code", + "baseName": "code", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return ErrorModel.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts b/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts new file mode 100644 index 000000000000..cf0b46b68f13 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts @@ -0,0 +1,26 @@ +/* + TODO: LICENSE INFO +*/ +import { ErrorModel } from './ErrorModel'; + +export class ExtendedErrorModel extends ErrorModel { + 'rootCause': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "rootCause", + "baseName": "rootCause", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return super.getAttributeTypeMap().concat(ExtendedErrorModel.attributeTypeMap); + } + + public constructor() { + super(); + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index 6e0c08a9baf6..b5bac2477467 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -1,14 +1,24 @@ export * from './ApiResponse'; +export * from './Cat'; export * from './Category'; +export * from './Dog'; +export * from './ErrorModel'; +export * from './ExtendedErrorModel'; export * from './Order'; export * from './Pet'; +export * from './Pet2'; export * from './Tag'; export * from './User'; import { ApiResponse } from './ApiResponse'; +import { Cat, CatHuntingSkillEnum } from './Cat'; import { Category } from './Category'; +import { Dog } from './Dog'; +import { ErrorModel } from './ErrorModel'; +import { ExtendedErrorModel } from './ExtendedErrorModel'; import { Order , OrderStatusEnum } from './Order'; import { Pet , PetStatusEnum } from './Pet'; +import { Pet2 } from './Pet2'; import { Tag } from './Tag'; import { User } from './User'; @@ -25,15 +35,21 @@ let primitives = [ ]; let enumsMap: Set = new Set([ + "CatHuntingSkillEnum", "OrderStatusEnum", "PetStatusEnum", ]); let typeMap: {[index: string]: any} = { "ApiResponse": ApiResponse, + "Cat": Cat, "Category": Category, + "Dog": Dog, + "ErrorModel": ErrorModel, + "ExtendedErrorModel": ExtendedErrorModel, "Order": Order, "Pet": Pet, + "Pet2": Pet2, "Tag": Tag, "User": User, } diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index 049cb8c7140c..f4d97a729874 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -18,7 +18,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", @@ -53,6 +53,9 @@ export class Order { static getAttributeTypeMap() { return Order.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 6dc00c53671f..5ecf6920762c 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -20,7 +20,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", @@ -55,6 +55,9 @@ export class Pet { static getAttributeTypeMap() { return Pet.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Pet2.ts b/samples/client/petstore/typescript/builds/default/models/Pet2.ts new file mode 100644 index 000000000000..865be4493a5a --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/Pet2.ts @@ -0,0 +1,31 @@ +/* + TODO: LICENSE INFO +*/ + +export class Pet2 { + 'name': string; + 'petType': string; + + static readonly discriminator: string | undefined = "petType"; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "petType", + "baseName": "petType", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Pet2.attributeTypeMap; + } + + public constructor() { + this.petType = "Pet2"; + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index 1d11453712e8..044e5f8d2364 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -11,7 +11,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", @@ -26,5 +26,8 @@ export class Tag { static getAttributeTypeMap() { return Tag.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index d9510f87ca9a..d29220a33eb0 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -20,7 +20,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", @@ -65,5 +65,8 @@ export class User { static getAttributeTypeMap() { return User.attributeTypeMap; } + + public constructor() { + } } diff --git a/samples/client/petstore/typescript/builds/default/models/all.ts b/samples/client/petstore/typescript/builds/default/models/all.ts index 2edba7f0bd56..5b69a96a602a 100644 --- a/samples/client/petstore/typescript/builds/default/models/all.ts +++ b/samples/client/petstore/typescript/builds/default/models/all.ts @@ -1,6 +1,11 @@ export * from './ApiResponse' +export * from './Cat' export * from './Category' +export * from './Dog' +export * from './ErrorModel' +export * from './ExtendedErrorModel' export * from './Order' export * from './Pet' +export * from './Pet2' export * from './Tag' export * from './User' diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 8499e8bacad4..30171cf9f083 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -5,9 +5,14 @@ import { Observable, of } from 'rxjs'; import {mergeMap, map} from 'rxjs/operators'; import { ApiResponse } from '../models/ApiResponse'; +import { Cat } from '../models/Cat'; import { Category } from '../models/Category'; +import { Dog } from '../models/Dog'; +import { ErrorModel } from '../models/ErrorModel'; +import { ExtendedErrorModel } from '../models/ExtendedErrorModel'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; +import { Pet2 } from '../models/Pet2'; import { Tag } from '../models/Tag'; import { User } from '../models/User'; diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts index c449b9e5b8ea..f2d947179b97 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -3,9 +3,14 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { ApiResponse } from '../models/ApiResponse'; +import { Cat } from '../models/Cat'; import { Category } from '../models/Category'; +import { Dog } from '../models/Dog'; +import { ErrorModel } from '../models/ErrorModel'; +import { ExtendedErrorModel } from '../models/ExtendedErrorModel'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; +import { Pet2 } from '../models/Pet2'; import { Tag } from '../models/Tag'; import { User } from '../models/User'; import { ObservablePetApi } from './ObservableAPI'; From 56ca583b2ee8ff650e97097ae21990ce5894bbe0 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 19:51:23 +0100 Subject: [PATCH 38/85] Set discriminator value automatically --- .../typescript/builds/default/models/Cat.ts | 36 ------------------- .../typescript/builds/default/models/Dog.ts | 33 ----------------- .../builds/default/models/ErrorModel.ts | 30 ---------------- .../default/models/ExtendedErrorModel.ts | 26 -------------- .../builds/default/models/ObjectSerializer.ts | 16 --------- .../typescript/builds/default/models/Pet2.ts | 31 ---------------- .../typescript/builds/default/models/all.ts | 5 --- .../builds/default/types/ObservableAPI.ts | 5 --- .../builds/default/types/PromiseAPI.ts | 5 --- 9 files changed, 187 deletions(-) delete mode 100644 samples/client/petstore/typescript/builds/default/models/Cat.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/Dog.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/ErrorModel.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts delete mode 100644 samples/client/petstore/typescript/builds/default/models/Pet2.ts diff --git a/samples/client/petstore/typescript/builds/default/models/Cat.ts b/samples/client/petstore/typescript/builds/default/models/Cat.ts deleted file mode 100644 index 7474d1a8ad6d..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/Cat.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - TODO: LICENSE INFO -*/ -import { Pet2 } from './Pet2'; - -/** -* A representation of a cat -*/ -export class Cat extends Pet2 { - /** - * The measured skill for hunting - */ - 'huntingSkill': CatHuntingSkillEnum; - - static readonly discriminator: string | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "huntingSkill", - "baseName": "huntingSkill", - "type": "CatHuntingSkillEnum" - } ]; - - static getAttributeTypeMap() { - return super.getAttributeTypeMap().concat(Cat.attributeTypeMap); - } - - public constructor() { - super(); - this.petType = "Cat"; - } -} - - -export type CatHuntingSkillEnum = "clueless" | "lazy" | "adventurous" | "aggressive" ; - diff --git a/samples/client/petstore/typescript/builds/default/models/Dog.ts b/samples/client/petstore/typescript/builds/default/models/Dog.ts deleted file mode 100644 index 27db62144300..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/Dog.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - TODO: LICENSE INFO -*/ -import { Pet2 } from './Pet2'; - -/** -* A representation of a dog -*/ -export class Dog extends Pet2 { - /** - * the size of the pack the dog is from - */ - 'packSize': number; - - static readonly discriminator: string | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "packSize", - "baseName": "packSize", - "type": "number" - } ]; - - static getAttributeTypeMap() { - return super.getAttributeTypeMap().concat(Dog.attributeTypeMap); - } - - public constructor() { - super(); - this.petType = "Dog"; - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts b/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts deleted file mode 100644 index 9dc7a6e1ae45..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/ErrorModel.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - TODO: LICENSE INFO -*/ - -export class ErrorModel { - 'message': string; - 'code': number; - - static readonly discriminator: string | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "message", - "baseName": "message", - "type": "string" - }, - { - "name": "code", - "baseName": "code", - "type": "number" - } ]; - - static getAttributeTypeMap() { - return ErrorModel.attributeTypeMap; - } - - public constructor() { - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts b/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts deleted file mode 100644 index cf0b46b68f13..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/ExtendedErrorModel.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - TODO: LICENSE INFO -*/ -import { ErrorModel } from './ErrorModel'; - -export class ExtendedErrorModel extends ErrorModel { - 'rootCause': string; - - static readonly discriminator: string | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "rootCause", - "baseName": "rootCause", - "type": "string" - } ]; - - static getAttributeTypeMap() { - return super.getAttributeTypeMap().concat(ExtendedErrorModel.attributeTypeMap); - } - - public constructor() { - super(); - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index b5bac2477467..6e0c08a9baf6 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -1,24 +1,14 @@ export * from './ApiResponse'; -export * from './Cat'; export * from './Category'; -export * from './Dog'; -export * from './ErrorModel'; -export * from './ExtendedErrorModel'; export * from './Order'; export * from './Pet'; -export * from './Pet2'; export * from './Tag'; export * from './User'; import { ApiResponse } from './ApiResponse'; -import { Cat, CatHuntingSkillEnum } from './Cat'; import { Category } from './Category'; -import { Dog } from './Dog'; -import { ErrorModel } from './ErrorModel'; -import { ExtendedErrorModel } from './ExtendedErrorModel'; import { Order , OrderStatusEnum } from './Order'; import { Pet , PetStatusEnum } from './Pet'; -import { Pet2 } from './Pet2'; import { Tag } from './Tag'; import { User } from './User'; @@ -35,21 +25,15 @@ let primitives = [ ]; let enumsMap: Set = new Set([ - "CatHuntingSkillEnum", "OrderStatusEnum", "PetStatusEnum", ]); let typeMap: {[index: string]: any} = { "ApiResponse": ApiResponse, - "Cat": Cat, "Category": Category, - "Dog": Dog, - "ErrorModel": ErrorModel, - "ExtendedErrorModel": ExtendedErrorModel, "Order": Order, "Pet": Pet, - "Pet2": Pet2, "Tag": Tag, "User": User, } diff --git a/samples/client/petstore/typescript/builds/default/models/Pet2.ts b/samples/client/petstore/typescript/builds/default/models/Pet2.ts deleted file mode 100644 index 865be4493a5a..000000000000 --- a/samples/client/petstore/typescript/builds/default/models/Pet2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - TODO: LICENSE INFO -*/ - -export class Pet2 { - 'name': string; - 'petType': string; - - static readonly discriminator: string | undefined = "petType"; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ - { - "name": "name", - "baseName": "name", - "type": "string" - }, - { - "name": "petType", - "baseName": "petType", - "type": "string" - } ]; - - static getAttributeTypeMap() { - return Pet2.attributeTypeMap; - } - - public constructor() { - this.petType = "Pet2"; - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/all.ts b/samples/client/petstore/typescript/builds/default/models/all.ts index 5b69a96a602a..2edba7f0bd56 100644 --- a/samples/client/petstore/typescript/builds/default/models/all.ts +++ b/samples/client/petstore/typescript/builds/default/models/all.ts @@ -1,11 +1,6 @@ export * from './ApiResponse' -export * from './Cat' export * from './Category' -export * from './Dog' -export * from './ErrorModel' -export * from './ExtendedErrorModel' export * from './Order' export * from './Pet' -export * from './Pet2' export * from './Tag' export * from './User' diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 30171cf9f083..8499e8bacad4 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -5,14 +5,9 @@ import { Observable, of } from 'rxjs'; import {mergeMap, map} from 'rxjs/operators'; import { ApiResponse } from '../models/ApiResponse'; -import { Cat } from '../models/Cat'; import { Category } from '../models/Category'; -import { Dog } from '../models/Dog'; -import { ErrorModel } from '../models/ErrorModel'; -import { ExtendedErrorModel } from '../models/ExtendedErrorModel'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; -import { Pet2 } from '../models/Pet2'; import { Tag } from '../models/Tag'; import { User } from '../models/User'; diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts index f2d947179b97..c449b9e5b8ea 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -3,14 +3,9 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { ApiResponse } from '../models/ApiResponse'; -import { Cat } from '../models/Cat'; import { Category } from '../models/Category'; -import { Dog } from '../models/Dog'; -import { ErrorModel } from '../models/ErrorModel'; -import { ExtendedErrorModel } from '../models/ExtendedErrorModel'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; -import { Pet2 } from '../models/Pet2'; import { Tag } from '../models/Tag'; import { User } from '../models/User'; import { ObservablePetApi } from './ObservableAPI'; From 7a372acbed5bad1c088b761299ca29b16cbc081b Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 9 Mar 2019 22:05:23 +0100 Subject: [PATCH 39/85] Fixed date-time and date handling --- .../codegen/CodegenOperation.java | 4 +- .../resources/typescript/api/api.mustache | 8 +- .../generators/types/ObservableAPI.mustache | 10 +- .../generators/types/PromiseAPI.mustache | 6 +- .../model/ObjectSerializer.mustache | 23 +- .../resources/typescript/model/model.mustache | 5 +- .../typescript/builds/default/PromiseAPI.ts | 440 ------------------ .../typescript/builds/default/apis/PetApi.ts | 22 +- .../builds/default/apis/StoreApi.ts | 12 +- .../typescript/builds/default/apis/UserApi.ts | 12 +- .../builds/default/models/ApiResponse.ts | 11 +- .../builds/default/models/Category.ts | 8 +- .../builds/default/models/ObjectSerializer.ts | 23 +- .../typescript/builds/default/models/Order.ts | 20 +- .../typescript/builds/default/models/Pet.ts | 20 +- .../typescript/builds/default/models/Tag.ts | 8 +- .../typescript/builds/default/models/User.ts | 26 +- .../builds/default/types/ObservableAPI.ts | 30 +- .../builds/default/types/PromiseAPI.ts | 18 +- .../test/models/ObjectSerializer.test.ts | 54 ++- 20 files changed, 193 insertions(+), 567 deletions(-) delete mode 100644 samples/client/petstore/typescript/builds/default/PromiseAPI.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java index 117eb9a1ed3b..f1e68818cc9f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java @@ -30,8 +30,8 @@ public class CodegenOperation { isResponseBinary = false, isResponseFile = false, hasReference = false, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy, isRestful, isDeprecated, isCallbackRequest; - public String path, operationId, returnType, httpMethod, returnBaseType, - returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse; + public String path, operationId, returnType, returnFormat, httpMethod, returnBaseType, + returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse; public CodegenDiscriminator discriminator; public List> consumes, produces, prioritizedContentTypes; public List servers = new ArrayList(); diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 074b3fa3a145..bbcfa1bc754c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -40,13 +40,13 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Query Params {{#queryParams}} if ({{paramName}} !== undefined) { - requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}")); } {{/queryParams}} // Header Params {{#headerParams}} - requestContext.setHeaderParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + requestContext.setHeaderParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}")); {{/headerParams}} // Form Params @@ -133,7 +133,7 @@ export class {{classname}}ResponseProcessor { if (isCodeInRange("{{code}}", response.httpStatusCode)) { {{#dataType}} const jsonBody = JSON.parse(response.body); - const body: {{{dataType}}} = ObjectSerializer.deserialize(jsonBody, "{{{dataType}}}") as {{{dataType}}}; + const body: {{{dataType}}} = ObjectSerializer.deserialize(jsonBody, "{{{dataType}}}", "{{returnFormat}}") as {{{dataType}}}; {{#isSuccessCode}} return body; {{/isSuccessCode}} @@ -156,7 +156,7 @@ export class {{classname}}ResponseProcessor { if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { {{#returnType}} const jsonBody = JSON.parse(response.body); - const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}") as {{{returnType}}}; + const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}", "{{returnFormat}}") as {{{returnType}}}; return body; {{/returnType}} {{^returnType}} diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache index a8e02e4ba949..978d2636cf9c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache @@ -17,10 +17,12 @@ import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../a export class Observable{{classname}} { private requestFactory: {{classname}}RequestFactory; private responseProcessor: {{classname}}ResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new {{classname}}RequestFactory(configuration); - this.responseProcessor = new {{classname}}ResponseProcessor(); + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: {{classname}}RequestFactory, responseProcessor?: {{classname}}ResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new {{classname}}RequestFactory(configuration); + this.responseProcessor = responseProcessor || new {{classname}}ResponseProcessor(); } {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache index 4f1ea13cdef0..a443dd699587 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache @@ -16,9 +16,9 @@ import { Observable{{classname}} } from './ObservableAPI'; import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; export class Promise{{classname}} { private api: Observable{{classname}} - - public constructor(configuration: Configuration) { - this.api = new Observable{{classname}}(configuration); + + public constructor(configuration: Configuration, requestFactory?: {{classname}}RequestFactory, responseProcessor?: {{classname}}ResponseProcessor) { + this.api = new Observable{{classname}}(configuration, requestFactory, responseProcessor); } {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 4655727b1899..e751e2d047c6 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -80,7 +80,7 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string, format: string) { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { @@ -91,11 +91,20 @@ export class ObjectSerializer { let transformedData: any[] = []; for (let index in data) { let date = data[index]; - transformedData.push(ObjectSerializer.serialize(date, subType)); + transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; } else if (type === "Date") { - return data.toISOString(); + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } } else { if (enumsMap.has(type)) { return data; @@ -112,13 +121,13 @@ export class ObjectSerializer { let instance: {[index: string]: any} = {}; for (let index in attributeTypes) { let attributeType = attributeTypes[index]; - instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string, format: string) { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { @@ -131,7 +140,7 @@ export class ObjectSerializer { let transformedData: any[] = []; for (let index in data) { let date = data[index]; - transformedData.push(ObjectSerializer.deserialize(date, subType)); + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; } else if (type === "Date") { @@ -148,7 +157,7 @@ export class ObjectSerializer { let attributeTypes = typeMap[type].getAttributeTypeMap(); for (let index in attributeTypes) { let attributeType = attributeTypes[index]; - instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); } return instance; } diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 78eae0ec438b..b3539527bd41 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -28,12 +28,13 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/discriminator}} {{^isArrayModel}} - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ {{#vars}} { "name": "{{name}}", "baseName": "{{baseName}}", - "type": "{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}" + "type": "{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}", + "format": "{{dataFormat}}" }{{#hasMore}}, {{/hasMore}} {{/vars}} diff --git a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/PromiseAPI.ts deleted file mode 100644 index 9306e5f30f72..000000000000 --- a/samples/client/petstore/typescript/builds/default/PromiseAPI.ts +++ /dev/null @@ -1,440 +0,0 @@ -import { ResponseContext, RequestContext, HttpFile } from './http/http'; -import * as models from './models/all'; -import { Configuration} from './configuration' -import { Observable, of } from 'rxjs'; -import {mergeMap, map} from 'rxjs/operators'; - -import { ApiResponse } from './models/ApiResponse'; -import { Category } from './models/Category'; -import { Order } from './models/Order'; -import { Pet } from './models/Pet'; -import { Tag } from './models/Tag'; -import { User } from './models/User'; - -import { PetApiRequestFactory, PetApiResponseProcessor} from "./apis/PetApi"; -export class PetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new PetApiRequestFactory(configuration); - this.responseProcessor = new PetApiResponseProcessor(); - } - - public addPet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(pet, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); - })); - } - - public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deletePet(petId, apiKey, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); - })); - } - - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByStatus(status, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); - })); - } - - public findPetsByTags(tags: Array, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByTags(tags, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); - })); - } - - public getPetById(petId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getPetById(petId, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); - })); - } - - public updatePet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(pet, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); - })); - } - - public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); - })); - } - - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { - const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); - })); - } - - -} - - - - -import { StoreApiRequestFactory, StoreApiResponseProcessor} from "./apis/StoreApi"; -export class StoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new StoreApiRequestFactory(configuration); - this.responseProcessor = new StoreApiResponseProcessor(); - } - - public deleteOrder(orderId: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteOrder(orderId, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); - })); - } - - public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { - const requestContext = this.requestFactory.getInventory(options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); - })); - } - - public getOrderById(orderId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getOrderById(orderId, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); - })); - } - - public placeOrder(order: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(order, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); - })); - } - - -} - - - - -import { UserApiRequestFactory, UserApiResponseProcessor} from "./apis/UserApi"; -export class UserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new UserApiRequestFactory(configuration); - this.responseProcessor = new UserApiResponseProcessor(); - } - - public createUser(user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(user, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); - })); - } - - public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); - })); - } - - public createUsersWithListInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(user, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); - })); - } - - public deleteUser(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteUser(username, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); - })); - } - - public getUserByName(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.getUserByName(username, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); - })); - } - - public loginUser(username: string, password: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.loginUser(username, password, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); - })); - } - - public logoutUser(options?: Configuration): Observable { - const requestContext = this.requestFactory.logoutUser(options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); - })); - } - - public updateUser(username: string, user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, user, options); - - // build promise chain - let middlewarePreObservable = of(requestContext); - for (let middleware of this.configuration.middleware) { - middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); - } - - return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). - pipe(mergeMap((response: ResponseContext) => { - let middlewarePostObservable = of(response); - for (let middleware of this.configuration.middleware) { - middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); - } - return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); - })); - } - - -} - - - diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 5bcbe793f1d8..3332177ebe0d 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -74,7 +74,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Query Params // Header Params - requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string")); + requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", "")); // Form Params @@ -109,7 +109,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Query Params if (status !== undefined) { - requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); + requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", "")); } // Header Params @@ -147,7 +147,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Query Params if (tags !== undefined) { - requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array")); + requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array", "")); } // Header Params @@ -388,7 +388,7 @@ export class PetApiResponseProcessor { public findPetsByStatus(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -398,7 +398,7 @@ export class PetApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; return body; } let body = response.body || ""; @@ -412,7 +412,7 @@ export class PetApiResponseProcessor { public findPetsByTags(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -422,7 +422,7 @@ export class PetApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array") as Array; + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; return body; } let body = response.body || ""; @@ -436,7 +436,7 @@ export class PetApiResponseProcessor { public getPetById(response: ResponseContext): Pet { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -449,7 +449,7 @@ export class PetApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet; + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; return body; } let body = response.body || ""; @@ -503,14 +503,14 @@ export class PetApiResponseProcessor { public uploadFile(response: ResponseContext): ApiResponse { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; return body; } // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; return body; } let body = response.body || ""; diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 9b9fbc5c5eeb..d082a4e2359b 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -173,14 +173,14 @@ export class StoreApiResponseProcessor { public getInventory(response: ResponseContext): { [key: string]: number; } { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; return body; } // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; return body; } let body = response.body || ""; @@ -194,7 +194,7 @@ export class StoreApiResponseProcessor { public getOrderById(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -207,7 +207,7 @@ export class StoreApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; return body; } let body = response.body || ""; @@ -221,7 +221,7 @@ export class StoreApiResponseProcessor { public placeOrder(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -231,7 +231,7 @@ export class StoreApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order; + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; return body; } let body = response.body || ""; diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index 469719a3fcd3..a2432fcbe830 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -203,10 +203,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Query Params if (username !== undefined) { - requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string")); + requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string", "")); } if (password !== undefined) { - requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string")); + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "")); } // Header Params @@ -373,7 +373,7 @@ export class UserApiResponseProcessor { public getUserByName(response: ResponseContext): User { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; + const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -386,7 +386,7 @@ export class UserApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User; + const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; return body; } let body = response.body || ""; @@ -400,7 +400,7 @@ export class UserApiResponseProcessor { public loginUser(response: ResponseContext): string { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; + const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -410,7 +410,7 @@ export class UserApiResponseProcessor { // Work around for incorrect api specification in petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string; + const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; return body; } let body = response.body || ""; diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index cc919118ae77..3c8a08e64744 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -12,21 +12,24 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", "baseName": "code", - "type": "number" + "type": "number", + "format": "int32" }, { "name": "type", "baseName": "type", - "type": "string" + "type": "string", + "format": "" }, { "name": "message", "baseName": "message", - "type": "string" + "type": "string", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index af9bdf34d545..50f44408282d 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -11,16 +11,18 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", "baseName": "id", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "name", "baseName": "name", - "type": "string" + "type": "string", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index 6e0c08a9baf6..f6ca619bf10b 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -74,7 +74,7 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string, format: string) { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { @@ -85,11 +85,20 @@ export class ObjectSerializer { let transformedData: any[] = []; for (let index in data) { let date = data[index]; - transformedData.push(ObjectSerializer.serialize(date, subType)); + transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; } else if (type === "Date") { - return data.toISOString(); + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } } else { if (enumsMap.has(type)) { return data; @@ -106,13 +115,13 @@ export class ObjectSerializer { let instance: {[index: string]: any} = {}; for (let index in attributeTypes) { let attributeType = attributeTypes[index]; - instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string, format: string) { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { @@ -125,7 +134,7 @@ export class ObjectSerializer { let transformedData: any[] = []; for (let index in data) { let date = data[index]; - transformedData.push(ObjectSerializer.deserialize(date, subType)); + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; } else if (type === "Date") { @@ -142,7 +151,7 @@ export class ObjectSerializer { let attributeTypes = typeMap[type].getAttributeTypeMap(); for (let index in attributeTypes) { let attributeType = attributeTypes[index]; - instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); } return instance; } diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index f4d97a729874..28e76713f0d7 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -18,36 +18,42 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", "baseName": "id", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "petId", "baseName": "petId", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "quantity", "baseName": "quantity", - "type": "number" + "type": "number", + "format": "int32" }, { "name": "shipDate", "baseName": "shipDate", - "type": "Date" + "type": "Date", + "format": "date-time" }, { "name": "status", "baseName": "status", - "type": "OrderStatusEnum" + "type": "OrderStatusEnum", + "format": "" }, { "name": "complete", "baseName": "complete", - "type": "boolean" + "type": "boolean", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 5ecf6920762c..7ec6d1d33787 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -20,36 +20,42 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", "baseName": "id", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "category", "baseName": "category", - "type": "Category" + "type": "Category", + "format": "" }, { "name": "name", "baseName": "name", - "type": "string" + "type": "string", + "format": "" }, { "name": "photoUrls", "baseName": "photoUrls", - "type": "Array" + "type": "Array", + "format": "" }, { "name": "tags", "baseName": "tags", - "type": "Array" + "type": "Array", + "format": "" }, { "name": "status", "baseName": "status", - "type": "PetStatusEnum" + "type": "PetStatusEnum", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index 044e5f8d2364..57c7872cc79d 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -11,16 +11,18 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", "baseName": "id", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "name", "baseName": "name", - "type": "string" + "type": "string", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index d29220a33eb0..d6ad51d3a1cf 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -20,46 +20,54 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", "baseName": "id", - "type": "number" + "type": "number", + "format": "int64" }, { "name": "username", "baseName": "username", - "type": "string" + "type": "string", + "format": "" }, { "name": "firstName", "baseName": "firstName", - "type": "string" + "type": "string", + "format": "" }, { "name": "lastName", "baseName": "lastName", - "type": "string" + "type": "string", + "format": "" }, { "name": "email", "baseName": "email", - "type": "string" + "type": "string", + "format": "" }, { "name": "password", "baseName": "password", - "type": "string" + "type": "string", + "format": "" }, { "name": "phone", "baseName": "phone", - "type": "string" + "type": "string", + "format": "" }, { "name": "userStatus", "baseName": "userStatus", - "type": "number" + "type": "number", + "format": "int32" } ]; static getAttributeTypeMap() { diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 8499e8bacad4..339c3e5c6a79 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -15,10 +15,12 @@ import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class ObservablePetApi { private requestFactory: PetApiRequestFactory; private responseProcessor: PetApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new PetApiRequestFactory(configuration); - this.responseProcessor = new PetApiResponseProcessor(); + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); } public addPet(pet: Pet, options?: Configuration): Observable { @@ -183,10 +185,12 @@ import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreA export class ObservableStoreApi { private requestFactory: StoreApiRequestFactory; private responseProcessor: StoreApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new StoreApiRequestFactory(configuration); - this.responseProcessor = new StoreApiResponseProcessor(); + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); } public deleteOrder(orderId: string, options?: Configuration): Observable { @@ -275,10 +279,12 @@ import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi" export class ObservableUserApi { private requestFactory: UserApiRequestFactory; private responseProcessor: UserApiResponseProcessor; - - public constructor(private configuration: Configuration) { - this.requestFactory = new UserApiRequestFactory(configuration); - this.responseProcessor = new UserApiResponseProcessor(); + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); } public createUser(user: User, options?: Configuration): Observable { diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts index c449b9e5b8ea..297fbd141385 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -14,9 +14,9 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class PromisePetApi { private api: ObservablePetApi - - public constructor(configuration: Configuration) { - this.api = new ObservablePetApi(configuration); + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); } public addPet(pet: Pet, options?: Configuration): Promise { @@ -70,9 +70,9 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class PromiseStoreApi { private api: ObservableStoreApi - - public constructor(configuration: Configuration) { - this.api = new ObservableStoreApi(configuration); + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); } public deleteOrder(orderId: string, options?: Configuration): Promise { @@ -106,9 +106,9 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class PromiseUserApi { private api: ObservableUserApi - - public constructor(configuration: Configuration) { - this.api = new ObservableUserApi(configuration); + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); } public createUser(user: User, options?: Configuration): Promise { diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index d35020f32096..e111dfe49e6b 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -12,44 +12,50 @@ describe("ObjectSerializer", () => { describe("Serialize", () => { it("String", () => { const input = "test string" - expect(ObjectSerializer.serialize(input, "string")).to.equal("test string") + expect(ObjectSerializer.serialize(input, "string", "")).to.equal("test string") }); it("Number", () => { const input = 1337 - expect(ObjectSerializer.serialize(input, "number")).to.equal(1337) + expect(ObjectSerializer.serialize(input, "number", "")).to.equal(1337) }); it("String Array", () => { const input = ["a", "b", "c"] - expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal(["a", "b", "c"]) + expect(ObjectSerializer.serialize(input, "Array", "")).to.deep.equal(["a", "b", "c"]) }) it("Number Array", () => { const input = [ 1337, 42, 0] - expect(ObjectSerializer.serialize(input, "Array")).to.deep.equal([1337, 42, 0]) + expect(ObjectSerializer.serialize(input, "Array", "")).to.deep.equal([1337, 42, 0]) }) - it("Date", () => { + it("Date-Time", () => { const input = new Date(1543777609696) - expect(ObjectSerializer.serialize(input, "Date")).to.equal(input.toISOString()) + expect(ObjectSerializer.serialize(input, "Date", "date-time")).to.equal(input.toISOString()) }) + it("Date-Time", () => { + const input = new Date(1543777609696) + expect(ObjectSerializer.serialize(input, "Date", "date")).to.equal("2018-12-02") + }) + + it("Object", () => { const input = {"a": "test", "b": { "test": 5}} - expect(ObjectSerializer.serialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5}}) + expect(ObjectSerializer.serialize(input, "Object", "")).to.deep.equal({ a: "test", "b": { "test": 5}}) }) it("Class", () => { const input = new petstore.models.Category() input.id = 4 input.name = "Test" - expect(ObjectSerializer.serialize(input, "Category")).to.deep.equal({ "id": input.id, "name": input.name}) + expect(ObjectSerializer.serialize(input, "Category", "")).to.deep.equal({ "id": input.id, "name": input.name}) }); it ("Enum", () => { const input = "available" - expect(ObjectSerializer.serialize(input, "Pet.StatusEnum")).to.equal("available") + expect(ObjectSerializer.serialize(input, "Pet.StatusEnum", "")).to.equal("available") }) it("Complex Class", () => { @@ -77,7 +83,7 @@ describe("ObjectSerializer", () => { pet.status = "available" pet.tags = tags - expect(ObjectSerializer.serialize(pet, "Pet")).to.deep.equal({ + expect(ObjectSerializer.serialize(pet, "Pet", "")).to.deep.equal({ "id": pet.id, "name": pet.name, "category": { @@ -103,39 +109,45 @@ describe("ObjectSerializer", () => { }) } - expect(ObjectSerializer.serialize(categories, "Array")).to.deep.equal(result) + expect(ObjectSerializer.serialize(categories, "Array", "")).to.deep.equal(result) }) }) describe("Deserialize", () => { it("String", () => { const input = "test string" - expect(ObjectSerializer.deserialize(input, "string")).to.equal("test string") + expect(ObjectSerializer.deserialize(input, "string", "")).to.equal("test string") }); it("Number", () => { const input = 1337 - expect(ObjectSerializer.deserialize(input, "number")).to.equal(1337) + expect(ObjectSerializer.deserialize(input, "number", "")).to.equal(1337) }); it("String Array", () => { const input = ["a", "b", "c"] - expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal(["a", "b", "c"]) + expect(ObjectSerializer.deserialize(input, "Array", "")).to.deep.equal(["a", "b", "c"]) }) it("Number Array", () => { const input = [ 1337, 42, 0] - expect(ObjectSerializer.deserialize(input, "Array")).to.deep.equal([1337, 42, 0]) + expect(ObjectSerializer.deserialize(input, "Array", "")).to.deep.equal([1337, 42, 0]) }) - it("Date", () => { + it("DateTime", () => { const input = new Date(1543777609696) - expect(ObjectSerializer.deserialize(input.toISOString(), "Date").getTime()).to.equal(input.getTime()) + expect(ObjectSerializer.deserialize(input.toISOString(), "Date", "date-time").getTime()).to.equal(input.getTime()) + }) + + it("Date", () => { + let dateString = "2019-02-01" + const input = new Date(dateString); + expect(ObjectSerializer.deserialize(dateString, "Date", "date").getTime()).to.equal(input.getTime()) }) it("Object", () => { const input = {"a": "test", "b": { "test": 5}} - expect(ObjectSerializer.deserialize(input, "Object")).to.deep.equal({ a: "test", "b": { "test": 5}}) + expect(ObjectSerializer.deserialize(input, "Object", "")).to.deep.equal({ a: "test", "b": { "test": 5}}) }) it("Class", () => { @@ -150,7 +162,7 @@ describe("ObjectSerializer", () => { it ("Enum", () => { const input = "available" - expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum")).to.equal(input) + expect(ObjectSerializer.deserialize("available", "Pet.StatusEnum", "")).to.equal(input) }) it("Complex Class", () => { @@ -188,7 +200,7 @@ describe("ObjectSerializer", () => { "photoUrls": [ "url", "other url"], "status": "available", "tags": tagResult - }, "Pet") as petstore.models.Pet + }, "Pet", "") as petstore.models.Pet expect(deserialized.constructor.name).to.equal("Pet") expect(deserialized.category.constructor.name).to.equal("Category") @@ -212,7 +224,7 @@ describe("ObjectSerializer", () => { }) } - const deserialized = ObjectSerializer.deserialize(result, "Array") + const deserialized = ObjectSerializer.deserialize(result, "Array", "") for (let i = 0; i < categories.length; i++) { expect(deserialized[i].constructor.name).to.equal("Category") } From 35d3cc20c9252b7f6ec7741abd000678ad3515eb Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Tue, 30 Apr 2019 19:01:43 +0200 Subject: [PATCH 40/85] Added comments & license info --- .../resources/typescript/api/api.mustache | 22 +++++++-- .../typescript/api/exception.mustache | 9 ++++ .../typescript/api/middleware.mustache | 38 +++++++++++++++ .../resources/typescript/auth/auth.mustache | 46 ++++++++++++++++++- .../typescript/configuration.mustache | 34 ++++++++++++-- .../generators/types/ObservableAPI.mustache | 11 +++++ .../generators/types/PromiseAPI.mustache | 11 +++++ .../resources/typescript/http/http.mustache | 41 +++++++++++++++-- .../typescript/http/servers.mustache | 21 ++++++++- .../resources/typescript/licenseInfo.mustache | 14 ++++-- .../main/resources/typescript/util.mustache | 8 ++++ 11 files changed, 237 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index bbcfa1bc754c..ed67714c2011 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -12,10 +12,23 @@ import { {{classname}} } from '..{{filename}}'; {{/imports}} {{#operations}} +/** + * {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}} + */ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { - // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{paramName}} {{description}} + {{/allParams}} + */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): RequestContext { let config = options || this.configuration; {{#allParams}} @@ -116,8 +129,6 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { } {{/operations}} -// TODO: find way to split these two files (both dependent on apitemplatefiles) - {{#operations}} @@ -125,7 +136,10 @@ export class {{classname}}ResponseProcessor { {{#operation}} /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to {{nicknam}} * @throws ApiException if the response code was not in [200, 299] */ public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { diff --git a/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache index c5dd10fa4387..b76dca5aa4bc 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/exception.mustache @@ -1,3 +1,12 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ export class ApiException extends Error { public constructor(public code: number, public body: T) { super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index 89a895a32b4b..f3b038ea17cb 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -1,8 +1,27 @@ import {RequestContext, ResponseContext} from './http/http'; import { Observable, from } from 'rxjs'; +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ post(context: ResponseContext): Observable; } @@ -22,7 +41,26 @@ export class PromiseMiddlewareWrapper implements Middleware { } +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ post(context: ResponseContext): Observable; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 815c5b09642f..75374bd2b738 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -3,6 +3,10 @@ import {RequestContext} from '../http/http'; //@ts-ignore import * as btoa from "btoa"; +/** + * Base class for all authentication schemes. + * + */ export abstract class SecurityAuthentication { public constructor(private name: string) { @@ -17,10 +21,19 @@ export abstract class SecurityAuthentication { return this.name; } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ public abstract applySecurityAuthentication(context: RequestContext): void; } +/** + * Applies no authentication. + * + */ export class NoAuthentication extends SecurityAuthentication { public constructor() { @@ -32,12 +45,24 @@ export class NoAuthentication extends SecurityAuthentication { } } +/** + * Applies an api key to the request context. + * + */ export class APIKeyAuthentication extends SecurityAuthentication { + /** + * Configures this api key authentication with the necessary properties + * + * @param authName: name of this authentication scheme as specified in the swagger.json + * @param paramName: Parameter name used for the api key + * @param keyLocation: Parameter location, either query, header or cookie. + * @param apiKey: The api key to be used for every request + */ public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -48,10 +73,22 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } -// TODO: guarantee that auth was configured properly + +/** + * Applies basic http authentication to a request. + * + */ export class HttpBasicAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in swagger json + * @param username username for http basic authentication + * @param password password for http basic authentication + */ public constructor(authName: string, private username: string, private password: string) { super(authName); } @@ -62,6 +99,7 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } +// TODO: How to handle oauth2 authentication! export class OAuth2Authentication extends SecurityAuthentication { public constructor(authName: string) { super(authName); @@ -84,6 +122,10 @@ export type OAuth2Configuration = string; export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isHttp}}HttpBasicConfiguration{{/isHttp}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } +/** + * Creates the authentication methods from a swagger description. + * + */ export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { let authMethods: AuthMethods = { } diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index c31ae8fb359f..73f53c7dd211 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -4,12 +4,30 @@ import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; - +/** + * Inetrface with which a configuration object can be configured. + * + */ export interface ConfigurationParameters { + /** + * Default server to use + */ baseServer?: ServerConfiguration; - httpApi?: HttpLibrary; // override for fetch implementation + /** + * HTTP library to use e.g. IsomorphicFetch + */ + httpApi?: HttpLibrary; + /** + * The middlewares which will be applied to requests and responses + */ middleware?: Middleware[]; // middleware to apply before/after fetch requests + /** + * configures all middlewares using the promise api instead of observables (which Middleware uses) + */ promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods + */ authMethods?: AuthMethodsConfiguration } @@ -20,9 +38,19 @@ export class Configuration { middleware: Middleware[]; authMethods: AuthMethods; + /** + * Creates a new configuration object based on the given configuration. + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * @param conf particial configuration + */ constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? + this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); if (conf.promiseMiddleware) { diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache index 978d2636cf9c..75a48dea6456 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache @@ -26,6 +26,17 @@ export class Observable{{classname}} { } {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{paramName}} {{description}} + {{/allParams}} + */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache index a443dd699587..4f6227d57e9c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache @@ -22,6 +22,17 @@ export class Promise{{classname}} { } {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{paramName}} {{description}} + {{/allParams}} + */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { const result = this.api.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); return result.toPromise(); diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 5bd5f8229ed5..0da0d8125404 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -8,6 +8,9 @@ import { Observable } from 'rxjs'; export * from './isomorphic-fetch'; +/** + * Represents a HTTP Method. + */ export enum HttpMethod { GET = "GET", HEAD = "HEAD", @@ -19,16 +22,15 @@ export enum HttpMethod { TRACE = "TRACE", PATCH = "PATCH" } + +/** + * Represents a http file which will be uploaded to a server. + */ export interface HttpFile { data: Buffer; name: string; } -export interface FormEntry { - contentDisposition: string; - value: string | Blob; -} - export class HttpException extends Error { public constructor(msg: string) { @@ -36,24 +38,49 @@ export class HttpException extends Error { } } +/** + * Represents a HTTP request context + * + */ export class RequestContext { private headers: { [key: string]: string } = {}; private body: string | FormData = ""; private url: URLParse; + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ public constructor(url: string, private httpMethod: HttpMethod) { this.url = URLParse(url, true); } + /* + * Returns the url set in the constructor including the query string + * + */ public getUrl(): string { return this.url.toString(); } + /** + * Replaces the url set in the constructor with this url. + * + */ public setUrl(url: string) { this.url = URLParse(url, true); } + /** + * Sets the body of the http request either as a string or FormData + * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section + * 4.3 and this method throws an HttpException accordingly. + * + * @param body the body of the request + */ public setBody(body: string | FormData) { // HTTP-Spec 1.1 Section 4.3 if (this.httpMethod === HttpMethod.GET) { @@ -85,6 +112,10 @@ export class RequestContext { this.url.set("query", queryObj); } + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ public addCookie(name: string, value: string): void { if (!this.headers["Cookie"]) { this.headers["Cookie"] = ""; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache index 3b7065193228..db4ea7a9dd39 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache @@ -1,10 +1,21 @@ import {RequestContext, HttpMethod} from './http/http'; +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ export class ServerConfiguration { public constructor(private url: string, private variableConfiguration: T) { } + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ public setVariables(variableConfiguration: Partial) { for (const key in variableConfiguration) { const val = variableConfiguration[key] @@ -27,7 +38,15 @@ export class ServerConfiguration { } return replacedUrl } - + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { return new RequestContext(this.getUrl() + endpoint, httpMethod); } diff --git a/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache index e4d6f0225775..469fb03940fe 100644 --- a/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/licenseInfo.mustache @@ -1,3 +1,11 @@ -/* - TODO: LICENSE INFO -*/ \ No newline at end of file +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ diff --git a/modules/openapi-generator/src/main/resources/typescript/util.mustache b/modules/openapi-generator/src/main/resources/typescript/util.mustache index af9085e7cbff..d1888434535c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/util.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/util.mustache @@ -1,3 +1,11 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ export function isCodeInRange(codeRange: string, code: number): boolean { // This is how the default value is encoded in OAG if (codeRange === "0") { From a481d0ce8385552364879f24be1414f2ba9aac4b Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Tue, 30 Apr 2019 23:15:37 +0200 Subject: [PATCH 41/85] Added comments --- .../typescript/builds/default/apis/PetApi.ts | 86 ++++++++++++++--- .../builds/default/apis/StoreApi.ts | 44 +++++++-- .../typescript/builds/default/apis/UserApi.ts | 82 +++++++++++++--- .../builds/default/apis/exception.ts | 9 ++ .../typescript/builds/default/auth/auth.ts | 46 ++++++++- .../builds/default/configuration.ts | 34 ++++++- .../typescript/builds/default/http/http.ts | 41 +++++++- .../typescript/builds/default/middleware.ts | 38 ++++++++ .../builds/default/models/ApiResponse.ts | 15 ++- .../builds/default/models/Category.ts | 15 ++- .../typescript/builds/default/models/Order.ts | 15 ++- .../typescript/builds/default/models/Pet.ts | 15 ++- .../typescript/builds/default/models/Tag.ts | 15 ++- .../typescript/builds/default/models/User.ts | 15 ++- .../typescript/builds/default/servers.ts | 21 ++++- .../builds/default/types/ObservableAPI.ts | 94 +++++++++++++++++++ .../builds/default/types/PromiseAPI.ts | 94 +++++++++++++++++++ .../typescript/builds/default/util.ts | 8 ++ 18 files changed, 629 insertions(+), 58 deletions(-) diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 3332177ebe0d..f23e9a964260 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -10,9 +10,15 @@ import {isCodeInRange} from '../util'; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; +/** + * no description + */ export class PetApiRequestFactory extends BaseAPIRequestFactory { - // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ public addPet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -53,6 +59,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -91,6 +102,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -129,6 +145,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ public findPetsByTags(tags: Array, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -167,6 +188,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ public getPetById(petId: number, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -203,6 +229,10 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ public updatePet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -243,6 +273,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * 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: number, name?: string, status?: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -291,6 +327,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -341,14 +383,15 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { } -// TODO: find way to split these two files (both dependent on apitemplatefiles) - export class PetApiResponseProcessor { /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public addPet(response: ResponseContext): void { @@ -365,7 +408,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public deletePet(response: ResponseContext): void { @@ -382,7 +428,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public findPetsByStatus(response: ResponseContext): Array { @@ -406,7 +455,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public findPetsByTags(response: ResponseContext): Array { @@ -430,7 +482,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public getPetById(response: ResponseContext): Pet { @@ -457,7 +512,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public updatePet(response: ResponseContext): void { @@ -480,7 +538,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public updatePetWithForm(response: ResponseContext): void { @@ -497,7 +558,10 @@ export class PetApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public uploadFile(response: ResponseContext): ApiResponse { diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index d082a4e2359b..9eac5d5d9390 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -9,9 +9,16 @@ import {isCodeInRange} from '../util'; import { Order } from '../models/Order'; +/** + * no description + */ export class StoreApiRequestFactory extends BaseAPIRequestFactory { - // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ public deleteOrder(orderId: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -43,6 +50,10 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ public getInventory(options?: Configuration): RequestContext { let config = options || this.configuration; @@ -72,6 +83,11 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ public getOrderById(orderId: number, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -103,6 +119,10 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ public placeOrder(order: Order, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -140,14 +160,15 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { } -// TODO: find way to split these two files (both dependent on apitemplatefiles) - export class StoreApiResponseProcessor { /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public deleteOrder(response: ResponseContext): void { @@ -167,7 +188,10 @@ export class StoreApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public getInventory(response: ResponseContext): { [key: string]: number; } { @@ -188,7 +212,10 @@ export class StoreApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public getOrderById(response: ResponseContext): Order { @@ -215,7 +242,10 @@ export class StoreApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public placeOrder(response: ResponseContext): Order { diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index a2432fcbe830..e0b7317d69a4 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -9,9 +9,16 @@ import {isCodeInRange} from '../util'; import { User } from '../models/User'; +/** + * no description + */ export class UserApiRequestFactory extends BaseAPIRequestFactory { - // TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ public createUser(user: User, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -47,6 +54,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -82,6 +93,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -117,6 +132,11 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ public deleteUser(username: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -148,6 +168,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ public getUserByName(username: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -179,6 +203,11 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ public loginUser(username: string, password: string, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -221,6 +250,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Logs out current logged in user session + */ public logoutUser(options?: Configuration): RequestContext { let config = options || this.configuration; @@ -245,6 +277,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ public updateUser(username: string, user: User, options?: Configuration): RequestContext { let config = options || this.configuration; @@ -289,14 +327,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { } -// TODO: find way to split these two files (both dependent on apitemplatefiles) - export class UserApiResponseProcessor { /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public createUser(response: ResponseContext): void { @@ -313,7 +352,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public createUsersWithArrayInput(response: ResponseContext): void { @@ -330,7 +372,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public createUsersWithListInput(response: ResponseContext): void { @@ -347,7 +392,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public deleteUser(response: ResponseContext): void { @@ -367,7 +415,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public getUserByName(response: ResponseContext): User { @@ -394,7 +445,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public loginUser(response: ResponseContext): string { @@ -418,7 +472,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public logoutUser(response: ResponseContext): void { @@ -435,7 +492,10 @@ export class UserApiResponseProcessor { } /** - * + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to * @throws ApiException if the response code was not in [200, 299] */ public updateUser(response: ResponseContext): void { diff --git a/samples/client/petstore/typescript/builds/default/apis/exception.ts b/samples/client/petstore/typescript/builds/default/apis/exception.ts index c5dd10fa4387..b76dca5aa4bc 100644 --- a/samples/client/petstore/typescript/builds/default/apis/exception.ts +++ b/samples/client/petstore/typescript/builds/default/apis/exception.ts @@ -1,3 +1,12 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ export class ApiException extends Error { public constructor(public code: number, public body: T) { super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/client/petstore/typescript/builds/default/auth/auth.ts index a04aeb110da1..40a1e2e77bd8 100644 --- a/samples/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/client/petstore/typescript/builds/default/auth/auth.ts @@ -3,6 +3,10 @@ import {RequestContext} from '../http/http'; //@ts-ignore import * as btoa from "btoa"; +/** + * Base class for all authentication schemes. + * + */ export abstract class SecurityAuthentication { public constructor(private name: string) { @@ -17,10 +21,19 @@ export abstract class SecurityAuthentication { return this.name; } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ public abstract applySecurityAuthentication(context: RequestContext): void; } +/** + * Applies no authentication. + * + */ export class NoAuthentication extends SecurityAuthentication { public constructor() { @@ -32,12 +45,24 @@ export class NoAuthentication extends SecurityAuthentication { } } +/** + * Applies an api key to the request context. + * + */ export class APIKeyAuthentication extends SecurityAuthentication { + /** + * Configures this api key authentication with the necessary properties + * + * @param authName: name of this authentication scheme as specified in the swagger.json + * @param paramName: Parameter name used for the api key + * @param keyLocation: Parameter location, either query, header or cookie. + * @param apiKey: The api key to be used for every request + */ public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -48,10 +73,22 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } -// TODO: guarantee that auth was configured properly + +/** + * Applies basic http authentication to a request. + * + */ export class HttpBasicAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in swagger json + * @param username username for http basic authentication + * @param password password for http basic authentication + */ public constructor(authName: string, private username: string, private password: string) { super(authName); } @@ -62,6 +99,7 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } +// TODO: How to handle oauth2 authentication! export class OAuth2Authentication extends SecurityAuthentication { public constructor(authName: string) { super(authName); @@ -83,6 +121,10 @@ export type OAuth2Configuration = string; export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } +/** + * Creates the authentication methods from a swagger description. + * + */ export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { let authMethods: AuthMethods = { } diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index c31ae8fb359f..73f53c7dd211 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -4,12 +4,30 @@ import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; - +/** + * Inetrface with which a configuration object can be configured. + * + */ export interface ConfigurationParameters { + /** + * Default server to use + */ baseServer?: ServerConfiguration; - httpApi?: HttpLibrary; // override for fetch implementation + /** + * HTTP library to use e.g. IsomorphicFetch + */ + httpApi?: HttpLibrary; + /** + * The middlewares which will be applied to requests and responses + */ middleware?: Middleware[]; // middleware to apply before/after fetch requests + /** + * configures all middlewares using the promise api instead of observables (which Middleware uses) + */ promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods + */ authMethods?: AuthMethodsConfiguration } @@ -20,9 +38,19 @@ export class Configuration { middleware: Middleware[]; authMethods: AuthMethods; + /** + * Creates a new configuration object based on the given configuration. + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * @param conf particial configuration + */ constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? + this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); if (conf.promiseMiddleware) { diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 5bd5f8229ed5..0da0d8125404 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -8,6 +8,9 @@ import { Observable } from 'rxjs'; export * from './isomorphic-fetch'; +/** + * Represents a HTTP Method. + */ export enum HttpMethod { GET = "GET", HEAD = "HEAD", @@ -19,16 +22,15 @@ export enum HttpMethod { TRACE = "TRACE", PATCH = "PATCH" } + +/** + * Represents a http file which will be uploaded to a server. + */ export interface HttpFile { data: Buffer; name: string; } -export interface FormEntry { - contentDisposition: string; - value: string | Blob; -} - export class HttpException extends Error { public constructor(msg: string) { @@ -36,24 +38,49 @@ export class HttpException extends Error { } } +/** + * Represents a HTTP request context + * + */ export class RequestContext { private headers: { [key: string]: string } = {}; private body: string | FormData = ""; private url: URLParse; + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ public constructor(url: string, private httpMethod: HttpMethod) { this.url = URLParse(url, true); } + /* + * Returns the url set in the constructor including the query string + * + */ public getUrl(): string { return this.url.toString(); } + /** + * Replaces the url set in the constructor with this url. + * + */ public setUrl(url: string) { this.url = URLParse(url, true); } + /** + * Sets the body of the http request either as a string or FormData + * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section + * 4.3 and this method throws an HttpException accordingly. + * + * @param body the body of the request + */ public setBody(body: string | FormData) { // HTTP-Spec 1.1 Section 4.3 if (this.httpMethod === HttpMethod.GET) { @@ -85,6 +112,10 @@ export class RequestContext { this.url.set("query", queryObj); } + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ public addCookie(name: string, value: string): void { if (!this.headers["Cookie"]) { this.headers["Cookie"] = ""; diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index 89a895a32b4b..f3b038ea17cb 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -1,8 +1,27 @@ import {RequestContext, ResponseContext} from './http/http'; import { Observable, from } from 'rxjs'; +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ post(context: ResponseContext): Observable; } @@ -22,7 +41,26 @@ export class PromiseMiddlewareWrapper implements Middleware { } +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ post(context: ResponseContext): Observable; } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index 3c8a08e64744..1e4383431b77 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index 50f44408282d..69d6879fb9bd 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + /** * A category for a pet diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index 28e76713f0d7..0ef6a1dbef14 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 7ec6d1d33787..cf45a4341f34 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + import { Category } from './Category'; import { Tag } from './Tag'; diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index 57c7872cc79d..53576de1f9d3 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + /** * A tag for a pet diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index d6ad51d3a1cf..71276892aa0b 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -1,6 +1,15 @@ -/* - TODO: LICENSE INFO -*/ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + /** * A User who is purchasing from the pet store diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts index 85aeaa2c8a86..2819fdbe4274 100644 --- a/samples/client/petstore/typescript/builds/default/servers.ts +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -1,10 +1,21 @@ import {RequestContext, HttpMethod} from './http/http'; +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ export class ServerConfiguration { public constructor(private url: string, private variableConfiguration: T) { } + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ public setVariables(variableConfiguration: Partial) { for (const key in variableConfiguration) { const val = variableConfiguration[key] @@ -27,7 +38,15 @@ export class ServerConfiguration { } return replacedUrl } - + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { return new RequestContext(this.getUrl() + endpoint, httpMethod); } diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 339c3e5c6a79..f005b321a375 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -23,6 +23,10 @@ export class ObservablePetApi { this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); } + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ public addPet(pet: Pet, options?: Configuration): Observable { const requestContext = this.requestFactory.addPet(pet, options); @@ -42,6 +46,11 @@ export class ObservablePetApi { })); } + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deletePet(petId, apiKey, options); @@ -61,6 +70,11 @@ export class ObservablePetApi { })); } + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { const requestContext = this.requestFactory.findPetsByStatus(status, options); @@ -80,6 +94,11 @@ export class ObservablePetApi { })); } + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ public findPetsByTags(tags: Array, options?: Configuration): Observable> { const requestContext = this.requestFactory.findPetsByTags(tags, options); @@ -99,6 +118,11 @@ export class ObservablePetApi { })); } + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ public getPetById(petId: number, options?: Configuration): Observable { const requestContext = this.requestFactory.getPetById(petId, options); @@ -118,6 +142,10 @@ export class ObservablePetApi { })); } + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ public updatePet(pet: Pet, options?: Configuration): Observable { const requestContext = this.requestFactory.updatePet(pet, options); @@ -137,6 +165,12 @@ export class ObservablePetApi { })); } + /** + * 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: number, name?: string, status?: string, options?: Configuration): Observable { const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); @@ -156,6 +190,12 @@ export class ObservablePetApi { })); } + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); @@ -193,6 +233,11 @@ export class ObservableStoreApi { this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); } + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ public deleteOrder(orderId: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deleteOrder(orderId, options); @@ -212,6 +257,10 @@ export class ObservableStoreApi { })); } + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { const requestContext = this.requestFactory.getInventory(options); @@ -231,6 +280,11 @@ export class ObservableStoreApi { })); } + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ public getOrderById(orderId: number, options?: Configuration): Observable { const requestContext = this.requestFactory.getOrderById(orderId, options); @@ -250,6 +304,10 @@ export class ObservableStoreApi { })); } + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ public placeOrder(order: Order, options?: Configuration): Observable { const requestContext = this.requestFactory.placeOrder(order, options); @@ -287,6 +345,11 @@ export class ObservableUserApi { this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); } + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ public createUser(user: User, options?: Configuration): Observable { const requestContext = this.requestFactory.createUser(user, options); @@ -306,6 +369,10 @@ export class ObservableUserApi { })); } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); @@ -325,6 +392,10 @@ export class ObservableUserApi { })); } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithListInput(user: Array, options?: Configuration): Observable { const requestContext = this.requestFactory.createUsersWithListInput(user, options); @@ -344,6 +415,11 @@ export class ObservableUserApi { })); } + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ public deleteUser(username: string, options?: Configuration): Observable { const requestContext = this.requestFactory.deleteUser(username, options); @@ -363,6 +439,10 @@ export class ObservableUserApi { })); } + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ public getUserByName(username: string, options?: Configuration): Observable { const requestContext = this.requestFactory.getUserByName(username, options); @@ -382,6 +462,11 @@ export class ObservableUserApi { })); } + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ public loginUser(username: string, password: string, options?: Configuration): Observable { const requestContext = this.requestFactory.loginUser(username, password, options); @@ -401,6 +486,9 @@ export class ObservableUserApi { })); } + /** + * Logs out current logged in user session + */ public logoutUser(options?: Configuration): Observable { const requestContext = this.requestFactory.logoutUser(options); @@ -420,6 +508,12 @@ export class ObservableUserApi { })); } + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ public updateUser(username: string, user: User, options?: Configuration): Observable { const requestContext = this.requestFactory.updateUser(username, user, options); diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts index 297fbd141385..9c6c49ae8d76 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -19,41 +19,81 @@ export class PromisePetApi { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); } + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ public addPet(pet: Pet, options?: Configuration): Promise { const result = this.api.addPet(pet, options); return result.toPromise(); } + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { const result = this.api.deletePet(petId, apiKey, options); return result.toPromise(); } + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { const result = this.api.findPetsByStatus(status, options); return result.toPromise(); } + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ public findPetsByTags(tags: Array, options?: Configuration): Promise> { const result = this.api.findPetsByTags(tags, options); return result.toPromise(); } + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ public getPetById(petId: number, options?: Configuration): Promise { const result = this.api.getPetById(petId, options); return result.toPromise(); } + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ public updatePet(pet: Pet, options?: Configuration): Promise { const result = this.api.updatePet(pet, options); return result.toPromise(); } + /** + * 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: number, name?: string, status?: string, options?: Configuration): Promise { const result = this.api.updatePetWithForm(petId, name, status, options); return result.toPromise(); } + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { const result = this.api.uploadFile(petId, additionalMetadata, file, options); return result.toPromise(); @@ -75,21 +115,39 @@ export class PromiseStoreApi { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); } + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ public deleteOrder(orderId: string, options?: Configuration): Promise { const result = this.api.deleteOrder(orderId, options); return result.toPromise(); } + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { const result = this.api.getInventory(options); return result.toPromise(); } + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ public getOrderById(orderId: number, options?: Configuration): Promise { const result = this.api.getOrderById(orderId, options); return result.toPromise(); } + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ public placeOrder(order: Order, options?: Configuration): Promise { const result = this.api.placeOrder(order, options); return result.toPromise(); @@ -111,41 +169,77 @@ export class PromiseUserApi { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); } + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ public createUser(user: User, options?: Configuration): Promise { const result = this.api.createUser(user, options); return result.toPromise(); } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { const result = this.api.createUsersWithArrayInput(user, options); return result.toPromise(); } + /** + * Creates list of users with given input array + * @param user List of user object + */ public createUsersWithListInput(user: Array, options?: Configuration): Promise { const result = this.api.createUsersWithListInput(user, options); return result.toPromise(); } + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ public deleteUser(username: string, options?: Configuration): Promise { const result = this.api.deleteUser(username, options); return result.toPromise(); } + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ public getUserByName(username: string, options?: Configuration): Promise { const result = this.api.getUserByName(username, options); return result.toPromise(); } + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ public loginUser(username: string, password: string, options?: Configuration): Promise { const result = this.api.loginUser(username, password, options); return result.toPromise(); } + /** + * Logs out current logged in user session + */ public logoutUser(options?: Configuration): Promise { const result = this.api.logoutUser(options); return result.toPromise(); } + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ public updateUser(username: string, user: User, options?: Configuration): Promise { const result = this.api.updateUser(username, user, options); return result.toPromise(); diff --git a/samples/client/petstore/typescript/builds/default/util.ts b/samples/client/petstore/typescript/builds/default/util.ts index af9085e7cbff..d1888434535c 100644 --- a/samples/client/petstore/typescript/builds/default/util.ts +++ b/samples/client/petstore/typescript/builds/default/util.ts @@ -1,3 +1,11 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ export function isCodeInRange(codeRange: string, code: number): boolean { // This is how the default value is encoded in OAG if (codeRange === "0") { From c330a9f8724597d34dec1d22d3477a594c819643 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 1 May 2019 10:43:47 +0200 Subject: [PATCH 42/85] Ignore openapi-generator-cli/bin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2b1fa3629b05..d8355b3df3bf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ out/ classpath.txt version.properties modules/openapi-generator-gradle-plugin/bin/ +modules/openapi-generator-cli/bin/ !modules/openapi-generator-cli/src/main/resources/version.properties .project .classpath From 40f3c4f4dd47e26c83c24cd99c2ee5e69b10650d Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 1 May 2019 10:45:07 +0200 Subject: [PATCH 43/85] Removed accidentally created generated code --- .../ts-fetch-client/.openapi-generator-ignore | 23 --------- .../.openapi-generator/VERSION | 1 - .../~/ts-fetch-client/README.md | 1 - .../~/ts-fetch-client/configuration.ts | 38 -------------- .../~/ts-fetch-client/http/http.ts | 51 ------------------- .../ts-fetch-client/http/isomorphic-fetch.ts | 38 -------------- .../~/ts-fetch-client/middleware.ts | 6 --- .../~/ts-fetch-client/package.json | 28 ---------- .../~/ts-fetch-client/tsconfig.json | 29 ----------- 9 files changed, 215 deletions(-) delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/README.md delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/package.json delete mode 100644 modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a38..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# 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 OpenAPI Generator 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 -# This 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 diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION b/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION deleted file mode 100644 index 717311e32e3c..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -unset \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/README.md b/modules/openapi-generator-cli/~/ts-fetch-client/README.md deleted file mode 100644 index ea786ff2cf69..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/README.md +++ /dev/null @@ -1 +0,0 @@ -readme \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts b/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts deleted file mode 100644 index 06cc0f09bdd3..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/configuration.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {HttpLibrary} from './http/http'; -import {Middleware} from './middleware'; - -export interface ConfigurationParameters { - basePath?: string; // override base path - httpApi?: HttpLibrary; // override for fetch implementation - middleware?: Middleware[]; // middleware to apply before/after fetch requests - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security -} - -export class Configuration { - - basePath: string; - httpApi: HttpLibrary; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; - if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; - } - if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; - } - } -} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts b/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts deleted file mode 100644 index 79391f8588c7..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/http/http.ts +++ /dev/null @@ -1,51 +0,0 @@ -export enum HttpMethod { - GET = "GET", - HEAD = "HEAD", - POST = "POST", - PUT = "PUT", - DELETE = "DELETE", - CONNECT = "CONNECT", - OPTIONS = "OPTIONS", - TRACE = "TRACE", - PATCH = "PATCH" -} - -export interface FormEntry { - contentType: string; - value: string | Blob; -} - -export type FormData = { [key: string]: FormEntry }; - - -export class RequestContext { - public headers: { [key: string]: string } = {}; - public body: string | FormData = ""; - - public constructor(public url: string, public httpMethod: HttpMethod) { - - } - - public addCookie(name: string, value: string): void { - if (!this.headers["Cookie"]) { - this.headers["Cookie"] = ""; - } - this.headers["Cookie"] += name + "=" + value + "; "; - } - - public setHeader(key: string, value: string): void { - this.headers[key] = value; - } -} - -export class ResponseContext { - - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { - } - -} - -export interface HttpLibrary { - send(request: RequestContext): Promise; -} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts b/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts deleted file mode 100644 index 47fb11c86e56..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/http/isomorphic-fetch.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import * as e6p from 'es6-promise' -e6p.polyfill(); -import 'isomorphic-fetch'; - -export class IsomorphicFetchHttpLibrary implements HttpLibrary { - - public send(request: RequestContext): Promise { - let method = request.httpMethod.toString(); - let body: string | FormData = ""; - if (typeof request.body === "string") { - body = request.body; - } else { - body = new FormData(); - for (const key in request.body) { - body.append(key, request.body[key].value); - } - } - - return fetch(request.url, { - method: method, - body: body, - headers: request.headers, - credentials: "same-origin" - }).then((resp) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body) => { - return new ResponseContext(resp.status, headers, body) - }); - }); - - } -} diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts b/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts deleted file mode 100644 index 17fdcc8ea6f4..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/middleware.ts +++ /dev/null @@ -1,6 +0,0 @@ -import {RequestContext, ResponseContext} from './http/http'; - -export interface Middleware { - pre?(context: RequestContext): Promise; - post?(context: ResponseContext): Promise; -} \ No newline at end of file diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/package.json b/modules/openapi-generator-cli/~/ts-fetch-client/package.json deleted file mode 100644 index 4b73dd96ff24..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "", - "version": "", - "description": "OpenAPI client for ", - "author": "OpenAPI-Generator Contributors", - "keywords": [ - "fetch", - "typescript", - "openapi-client", - "openapi-generator", - "" - ], - "license": "Unlicense", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "scripts" : { - "build": "tsc", - "prepublishOnly": "npm run build" - }, - "dependencies": { - "es6-promise": "^4.2.4", - "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34" - }, - "devDependencies": { - "typescript": "^2.9.2" - } -} diff --git a/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json b/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json deleted file mode 100644 index 4ef0a0278025..000000000000 --- a/modules/openapi-generator-cli/~/ts-fetch-client/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - /* Basic Options */ - "target": "es5", - "module": "commonjs", - "declaration": true, - - /* Additional Checks */ - "noUnusedLocals": true, /* Report errors on unused locals. */ - "noUnusedParameters": true, /* Report errors on unused parameters. */ - "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - "removeComments": true, - "sourceMap": true, - "outDir": "./dist", - "noLib": false, - "declaration": true, - "lib": [ "es6", "dom" ] - }, - "exclude": [ - "node_modules" - ], - "filesGlob": [ - "./**/*.ts", - ] - -} \ No newline at end of file From fcbecc4dbd559ad19fdcf228305978027d2bd167 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 1 May 2019 10:50:57 +0200 Subject: [PATCH 44/85] Fixed compilation issues in TypeScriptClientCodegen --- .../codegen/languages/TypeScriptClientCodegen.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 3c69beb3f238..b7751912c7ac 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -33,6 +33,9 @@ import java.io.File; import java.util.*; import java.util.Map.Entry; +import static org.openapitools.codegen.utils.StringUtils.camelize; +import static org.openapitools.codegen.utils.StringUtils.underscore; + public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptClientCodegen.class); @@ -162,7 +165,7 @@ public CodegenType getTag() { } @Override - public Map postProcessOperations(Map operations) { + public Map postProcessOperationsWithModels(Map operations, List models) { // Add additional filename information for model imports in the apis List> imports = (List>) operations.get("imports"); From 99c3dceae740604ccbecaf6219863f1122fed277 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 1 May 2019 11:26:25 +0200 Subject: [PATCH 45/85] Added typescript to docs/generators --- docs/generators.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/generators.md b/docs/generators.md index cc730aab7d88..04de34b9155c 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -62,6 +62,7 @@ The following generators are available: * [swift3-deprecated (deprecated)](generators/swift3-deprecated.md) * [swift4](generators/swift4.md) * [swift5 (beta)](generators/swift5.md) +* [typescript](generators/typescript.md) * [typescript-angular](generators/typescript-angular.md) * [typescript-angularjs](generators/typescript-angularjs.md) * [typescript-aurelia](generators/typescript-aurelia.md) From 495ce938f8510ba1ac8e8527e8508bd2e8b6c792 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 2 May 2019 15:10:13 +0200 Subject: [PATCH 46/85] Updated docs --- docs/generators/typescript.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/generators/typescript.md diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md new file mode 100644 index 000000000000..2cf632734794 --- /dev/null +++ b/docs/generators/typescript.md @@ -0,0 +1,15 @@ + +--- +id: generator-opts-client-typescript +title: Config Options for typescript +sidebar_label: typescript +--- + +| Option | Description | Values | Default | +| ------ | ----------- | ------ | ------- | +|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| +|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| +|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| +|supportsES6|Generate code that conforms to ES6.| |false| From 8d8e57f1f9f0340d9a6d2507d30b79f27e442c61 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Fri, 3 May 2019 20:22:29 +0200 Subject: [PATCH 47/85] Added gitignore and git_push --- .../languages/TypeScriptClientCodegen.java | 4 +- .../resources/typescript/.gitignore.mustache | 1 + .../resources/typescript/git_push.sh.mustache | 52 +++++++++++++++++++ .../typescript/builds/default/apis/PetApi.ts | 24 ++++----- .../builds/default/apis/StoreApi.ts | 12 ++--- .../typescript/builds/default/apis/UserApi.ts | 48 ++++++++--------- .../typescript/builds/default/git_push.sh | 52 +++++++++++++++++++ .../builds/default/types/ObservableAPI.ts | 42 +++++++-------- .../builds/default/types/PromiseAPI.ts | 42 +++++++-------- 9 files changed, 192 insertions(+), 85 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/.gitignore.mustache create mode 100755 modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache create mode 100644 samples/client/petstore/typescript/builds/default/git_push.sh diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index b7751912c7ac..6906f94a094d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -120,10 +120,12 @@ public TypeScriptClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false")); // TODO: gen package.json? - //Files for building our lib + //Documentation supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); + supportingFiles.add(new SupportingFile(".gitignore.mustache", "", ".gitignore")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); // Util supportingFiles.add(new SupportingFile("util.mustache", "", "util.ts")); diff --git a/modules/openapi-generator/src/main/resources/typescript/.gitignore.mustache b/modules/openapi-generator/src/main/resources/typescript/.gitignore.mustache new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/.gitignore.mustache @@ -0,0 +1 @@ +dist diff --git a/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache new file mode 100755 index 000000000000..8a32e53995d6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache @@ -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 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + 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 credential 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' + diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index f23e9a964260..83904063a7dc 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -17,14 +17,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Add a new pet to the store - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public addPet(pet: Pet, options?: Configuration): RequestContext { + public addPet(body: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling addPet.'); } @@ -46,7 +46,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; @@ -231,14 +231,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Update an existing pet - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public updatePet(pet: Pet, options?: Configuration): RequestContext { + public updatePet(body: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling updatePet.'); } @@ -260,7 +260,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(pet || {}) : (pet.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 9eac5d5d9390..55769fdc2491 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -121,14 +121,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** * Place an order for a pet - * @param order order placed for purchasing the pet + * @param body order placed for purchasing the pet */ - public placeOrder(order: Order, options?: Configuration): RequestContext { + public placeOrder(body: Order, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling placeOrder.'); } @@ -150,7 +150,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(order || {}) : (order.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index e0b7317d69a4..b3040726a8f0 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -17,14 +17,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { /** * This can only be done by the logged in user. * Create user - * @param user Created user object + * @param body Created user object */ - public createUser(user: User, options?: Configuration): RequestContext { + public createUser(body: User, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUser.'); } @@ -46,7 +46,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -56,14 +56,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { + public createUsersWithArrayInput(body: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } @@ -85,7 +85,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -95,14 +95,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { + public createUsersWithListInput(body: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithListInput.'); } @@ -124,7 +124,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -281,9 +281,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param user Updated user object + * @param body Updated user object */ - public updateUser(username: string, user: User, options?: Configuration): RequestContext { + public updateUser(username: string, body: User, options?: Configuration): RequestContext { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -292,9 +292,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { } - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling updateUser.'); } @@ -317,7 +317,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(user || {}) : (user.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods diff --git a/samples/client/petstore/typescript/builds/default/git_push.sh b/samples/client/petstore/typescript/builds/default/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/git_push.sh @@ -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 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="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="Minor update" + 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 credential 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' + diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index f005b321a375..079853bb913a 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -25,10 +25,10 @@ export class ObservablePetApi { /** * Add a new pet to the store - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public addPet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(pet, options); + public addPet(body: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.addPet(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -144,10 +144,10 @@ export class ObservablePetApi { /** * Update an existing pet - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public updatePet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(pet, options); + public updatePet(body: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePet(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -306,10 +306,10 @@ export class ObservableStoreApi { /** * Place an order for a pet - * @param order order placed for purchasing the pet + * @param body order placed for purchasing the pet */ - public placeOrder(order: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(order, options); + public placeOrder(body: Order, options?: Configuration): Observable { + const requestContext = this.requestFactory.placeOrder(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -348,10 +348,10 @@ export class ObservableUserApi { /** * This can only be done by the logged in user. * Create user - * @param user Created user object + * @param body Created user object */ - public createUser(user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(user, options); + public createUser(body: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUser(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -371,10 +371,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); + public createUsersWithArrayInput(body: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithArrayInput(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -394,10 +394,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithListInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(user, options); + public createUsersWithListInput(body: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithListInput(body, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -512,10 +512,10 @@ export class ObservableUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param user Updated user object + * @param body Updated user object */ - public updateUser(username: string, user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, user, options); + public updateUser(username: string, body: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.updateUser(username, body, options); // build promise chain let middlewarePreObservable = of(requestContext); diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts index 9c6c49ae8d76..9aabd2472684 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -21,10 +21,10 @@ export class PromisePetApi { /** * Add a new pet to the store - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public addPet(pet: Pet, options?: Configuration): Promise { - const result = this.api.addPet(pet, options); + public addPet(body: Pet, options?: Configuration): Promise { + const result = this.api.addPet(body, options); return result.toPromise(); } @@ -70,10 +70,10 @@ export class PromisePetApi { /** * Update an existing pet - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - public updatePet(pet: Pet, options?: Configuration): Promise { - const result = this.api.updatePet(pet, options); + public updatePet(body: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(body, options); return result.toPromise(); } @@ -146,10 +146,10 @@ export class PromiseStoreApi { /** * Place an order for a pet - * @param order order placed for purchasing the pet + * @param body order placed for purchasing the pet */ - public placeOrder(order: Order, options?: Configuration): Promise { - const result = this.api.placeOrder(order, options); + public placeOrder(body: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(body, options); return result.toPromise(); } @@ -172,28 +172,28 @@ export class PromiseUserApi { /** * This can only be done by the logged in user. * Create user - * @param user Created user object + * @param body Created user object */ - public createUser(user: User, options?: Configuration): Promise { - const result = this.api.createUser(user, options); + public createUser(body: User, options?: Configuration): Promise { + const result = this.api.createUser(body, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithArrayInput(user, options); + public createUsersWithArrayInput(body: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(body, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param user List of user object + * @param body List of user object */ - public createUsersWithListInput(user: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithListInput(user, options); + public createUsersWithListInput(body: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(body, options); return result.toPromise(); } @@ -238,10 +238,10 @@ export class PromiseUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param user Updated user object + * @param body Updated user object */ - public updateUser(username: string, user: User, options?: Configuration): Promise { - const result = this.api.updateUser(username, user, options); + public updateUser(username: string, body: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, body, options); return result.toPromise(); } From fb6f8c5344680253b832cb1c3861c4de18a9a5ec Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 5 May 2019 16:44:32 +0200 Subject: [PATCH 48/85] Added jquery library --- .../languages/TypeScriptClientCodegen.java | 61 +- .../typescript/configuration.mustache | 9 +- .../{fetch.mustache => fetch-api.mustache} | 0 .../typescript/generators/jquery.mustache | 19 + .../resources/typescript/http/http.mustache | 10 +- .../resources/typescript/http/jquery.mustache | 76 + .../resources/typescript/package.mustache | 10 +- .../typescript-jquery/default/api/StoreApi.ts | 1 - .../builds/default/http/isomorphic-fetch.ts | 3 +- .../typescript/builds/jquery/.gitignore | 1 + .../builds/jquery/.openapi-generator-ignore | 23 + .../builds/jquery/.openapi-generator/VERSION | 1 + .../typescript/builds/jquery/README.md | 1 + .../petstore/typescript/builds/jquery/TODO.md | 5 + .../typescript/builds/jquery/apis/PetApi.ts | 584 +++ .../typescript/builds/jquery/apis/StoreApi.ts | 271 ++ .../typescript/builds/jquery/apis/UserApi.ts | 517 +++ .../typescript/builds/jquery/apis/baseapi.ts | 37 + .../builds/jquery/apis/exception.ts | 14 + .../typescript/builds/jquery/auth/auth.ts | 145 + .../typescript/builds/jquery/configuration.ts | 60 + .../typescript/builds/jquery/git_push.sh | 52 + .../typescript/builds/jquery/http/http.ts | 140 + .../typescript/builds/jquery/http/jquery.ts | 76 + .../typescript/builds/jquery/index.ts | 19 + .../typescript/builds/jquery/middleware.ts | 66 + .../builds/jquery/models/ApiResponse.ts | 51 + .../builds/jquery/models/Category.ts | 44 + .../builds/jquery/models/ObjectSerializer.ts | 159 + .../typescript/builds/jquery/models/Order.ts | 78 + .../typescript/builds/jquery/models/Pet.ts | 80 + .../typescript/builds/jquery/models/Tag.ts | 44 + .../typescript/builds/jquery/models/User.ts | 89 + .../typescript/builds/jquery/models/all.ts | 6 + .../builds/jquery/package-lock.json | 241 ++ .../typescript/builds/jquery/package.json | 34 + .../typescript/builds/jquery/servers.ts | 55 + .../typescript/builds/jquery/tsconfig.json | 29 + .../builds/jquery/types/ObservableAPI.ts | 540 +++ .../builds/jquery/types/PromiseAPI.ts | 252 ++ .../petstore/typescript/builds/jquery/util.ts | 28 + .../typescript/tests/jquery/.gitignore | 1 + .../typescript/tests/jquery/index.html | 15 + .../tests/jquery/node-qunit-puppeteer.d.ts | 1 + .../typescript/tests/jquery/package-lock.json | 3463 +++++++++++++++++ .../typescript/tests/jquery/package.json | 41 + .../petstore/typescript/tests/jquery/pom.xml | 59 + .../typescript/tests/jquery/require1k.min.js | 1 + .../typescript/tests/jquery/test-runner.ts | 29 + .../tests/jquery/test/api/PetApi.test.ts | 121 + .../typescript/tests/jquery/test/api/pet.png | Bin 0 -> 1122 bytes .../tests/jquery/test/http/jquery.test.ts | 85 + .../petstore/typescript/tests/jquery/tests.ts | 9 + .../typescript/tests/jquery/tsconfig.json | 20 + .../typescript/tests/jquery/weback.config.js | 22 + .../typescript/tests/package-lock.json | 3 + 56 files changed, 7789 insertions(+), 12 deletions(-) rename modules/openapi-generator/src/main/resources/typescript/generators/{fetch.mustache => fetch-api.mustache} (100%) create mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache create mode 100644 samples/client/petstore/typescript/builds/jquery/.gitignore create mode 100644 samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript/builds/jquery/README.md create mode 100644 samples/client/petstore/typescript/builds/jquery/TODO.md create mode 100644 samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/apis/exception.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/auth/auth.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/configuration.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/git_push.sh create mode 100644 samples/client/petstore/typescript/builds/jquery/http/http.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/http/jquery.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/index.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/middleware.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/Category.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/Order.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/Pet.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/Tag.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/User.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/models/all.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/package-lock.json create mode 100644 samples/client/petstore/typescript/builds/jquery/package.json create mode 100644 samples/client/petstore/typescript/builds/jquery/servers.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/tsconfig.json create mode 100644 samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/util.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/.gitignore create mode 100644 samples/client/petstore/typescript/tests/jquery/index.html create mode 100644 samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/package-lock.json create mode 100644 samples/client/petstore/typescript/tests/jquery/package.json create mode 100644 samples/client/petstore/typescript/tests/jquery/pom.xml create mode 100644 samples/client/petstore/typescript/tests/jquery/require1k.min.js create mode 100644 samples/client/petstore/typescript/tests/jquery/test-runner.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/test/api/pet.png create mode 100644 samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/tests.ts create mode 100644 samples/client/petstore/typescript/tests/jquery/tsconfig.json create mode 100644 samples/client/petstore/typescript/tests/jquery/weback.config.js create mode 100644 samples/client/petstore/typescript/tests/package-lock.json diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 6906f94a094d..aa4576730ef6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -43,13 +43,26 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value"; private static final String UNDEFINED_VALUE = "undefined"; + private static final String FRAMEWORK_SWITCH = "framework"; + private static final String FRAMEWORK_SWITCH_DESC = "Specify the framework which should be used in the client code."; + private static final String[] FRAMEWORKS = { "fetch-api", "jquery" }; + private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; + private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)"; + + private final Map frameworkToHttpLibMap; + protected String modelPropertyNaming = "camelCase"; protected boolean supportsES6 = true; protected HashSet languageGenericTypes; public TypeScriptClientCodegen() { super(); - + + this.frameworkToHttpLibMap = new HashMap<>(); + this.frameworkToHttpLibMap.put("fetch-api", "isomorphic-fetch"); + this.frameworkToHttpLibMap.put("jquery", "jquery"); + + // clear import mapping (from default generator) as TS does not use it // at the moment importMapping.clear(); @@ -118,6 +131,18 @@ public TypeScriptClientCodegen() { 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")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); + + CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); + for (String option: TypeScriptClientCodegen.FRAMEWORKS) { + // TODO: improve description? + frameworkOption.addEnum(option, option); + } + frameworkOption.defaultValue(FRAMEWORKS[0]); + System.out.println("Added framework option"); + cliOptions.add(frameworkOption); + + // TODO: gen package.json? //Documentation @@ -132,7 +157,6 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("api/exception.mustache", "apis", "exception.ts")); // http supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); - supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts")); supportingFiles.add(new SupportingFile("http/servers.mustache", "servers.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); @@ -144,9 +168,6 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("generators/types/PromiseAPI.mustache", "types", "PromiseAPI.ts")); supportingFiles.add(new SupportingFile("generators/types/ObservableAPI.mustache", "types", "ObservableAPI.ts")); - - supportingFiles.add(new SupportingFile("generators/fetch.mustache", "index.ts")); - // models // TODO: properly set model and api packages this.setModelPackage(""); @@ -166,6 +187,20 @@ public CodegenType getTag() { return CodegenType.CLIENT; } + @Override + public Map postProcessSupportingFileData(Map objs) { + Map frameworks = new HashMap<>(); + for (String framework: FRAMEWORKS) { + frameworks.put(framework, framework.equals(additionalProperties.get(FRAMEWORK_SWITCH))); + } + objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH)); + objs.put("frameworks", frameworks); + + objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE)); + + return objs; + } + @Override public Map postProcessOperationsWithModels(Map operations, List models) { @@ -674,9 +709,23 @@ public void processOpts() { apiPackage = this.apiPackage + ".apis"; modelPackage = this.modelPackage + ".models"; testPackage = this.testPackage + ".tests"; + + if (additionalProperties.containsKey(FRAMEWORK_SWITCH)) { + supportingFiles.add(new SupportingFile("generators/" + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", "index.ts")); + } else { + additionalProperties.put(FRAMEWORK_SWITCH, FRAMEWORKS[0]); + supportingFiles.add(new SupportingFile("generators" + File.separator + FRAMEWORKS[0] + ".mustache", "index.ts")); + } + String httpLibName = this.getHttpLibForFramework(additionalProperties.get(FRAMEWORK_SWITCH).toString()); + supportingFiles.add(new SupportingFile("http" + File.separator + httpLibName + ".mustache", "http", httpLibName + ".ts")); } - @Override + private String getHttpLibForFramework(String object) { + return this.frameworkToHttpLibMap.get(object); + } + + + @Override public String getTypeDeclaration(Schema p) { Schema inner; if (ModelUtils.isArraySchema(p)) { diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 73f53c7dd211..68c503af56c4 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,6 +1,13 @@ import {HttpLibrary} from './http/http'; import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; +{{#frameworks}} +{{#fetch-api}} import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; +{{/fetch-api}} +{{#jquery}} +import {JQueryHttpLibrary} from "./http/jquery"; +{{/jquery}} +{{/frameworks}} import {ServerConfiguration, server1} from './servers'; import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; @@ -50,7 +57,7 @@ export class Configuration { */ constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? + this.httpApi = conf.httpApi || {{#frameworks}}{{#fetch-api}}new IsomorphicFetchHttpLibrary(){{/fetch-api}}{{#jquery}}new JQueryHttpLibrary{{/jquery}}{{/frameworks}}; // TODO: replace with window.fetch if available? this.middleware = conf.middleware || []; this.authMethods = configureAuthMethods(conf.authMethods); if (conf.promiseMiddleware) { diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/generators/fetch.mustache rename to modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache new file mode 100644 index 000000000000..ca1c5ff976ff --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache @@ -0,0 +1,19 @@ +import * as http from './http/http'; +import * as auth from './auth/auth'; +import {Middleware, PromiseMiddleware} from './middleware'; +import * as models from './models/all'; +import { Configuration} from './configuration' +import * as apis from './types/PromiseAPI'; +import * as exceptions from './apis/exception'; + +export { + http, + + auth, + Middleware, + PromiseMiddleware, + models, + Configuration, + apis, + exceptions +}; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 0da0d8125404..8678e655c1d1 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -5,8 +5,14 @@ import * as FormData from "form-data"; import * as URLParse from "url-parse"; import { Observable } from 'rxjs'; - +{{#frameworks}} +{{#fetch-api}} export * from './isomorphic-fetch'; +{{/fetch-api}} +{{#jquery}} +export * from './jquery'; +{{/jquery}} +{{/frameworks}} /** * Represents a HTTP Method. @@ -27,7 +33,7 @@ export enum HttpMethod { * Represents a http file which will be uploaded to a server. */ export interface HttpFile { - data: Buffer; + data: {{{fileContentDataType}}}; name: string; } diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache new file mode 100644 index 000000000000..fa82596128da --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -0,0 +1,76 @@ +import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import * as e6p from 'es6-promise' +import { from, Observable } from 'rxjs'; +e6p.polyfill(); +import * as $ from 'jquery'; +import * as FormData from "form-data"; +import { resolve } from 'dns'; + +export class JQueryHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + let headerParams = request.getHeaders() + + let requestOptions: any = { + url: request.getUrl(), + type: method, + headers: request.getHeaders(), + processData: false, + xhrFields: { withCredentials: true }, + data: body + }; + + if (request.getHeaders()['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.dataFilter = ((headerParams: { [key:string]: string}) => { + return (data: string, type: string) => { + if (headerParams["Accept"] == "application/json" && data == "") { + return "{}" + } else { + return data + } + } + })(headerParams); + + if (request.getHeaders()["Cookie"]) { + throw new HttpException("Setting the \"Cookie\"-Header field is blocked by every major browser when using jquery.ajax requests. Please switch to another library like fetch to enable this option"); + } + + if (body.constructor.name == "FormData") { + requestOptions.contentType = false; + } + const sentRequest = $.ajax(requestOptions); + + const resultPromise = new Promise((resolve, reject) => { + sentRequest.done((resp, _, jqXHR) => { + const headers = this.getResponseHeaders(jqXHR) + const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + resolve(result); + }) + sentRequest.fail((jqXHR: any) => { + const headers = this.getResponseHeaders(jqXHR) + const result = new ResponseContext(jqXHR.status, headers, jqXHR.responseText); + resolve(result); + }) + }) + return from(resultPromise); + } + + private getResponseHeaders(jqXHR: any): { [key: string]: string } { + const responseHeaders: { [key: string]: string } = {}; + var headers = jqXHR.getAllResponseHeaders(); + headers = headers.split("\n"); + headers.forEach(function (header: any) { + header = header.split(": "); + var key = header.shift(); + if (key.length == 0) return + // chrome60+ force lowercase, other browsers can be different + key = key.toLowerCase(); + responseHeaders[key] = header.join(": "); + }); + return responseHeaders + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 087e657262df..dbd976a82756 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -19,9 +19,17 @@ }, "dependencies": { "es6-promise": "^4.2.4", + {{#frameworks}} + {{#fetch-api}} "isomorphic-fetch": "^2.2.1", - "btoa": "^1.2.1", "@types/isomorphic-fetch": "0.0.34", + {{/fetch-api}} + {{#jquery}} + "@types/jquery": "^3.3.29", + "jquery": "^3.4.1", + {{/jquery}} + {{/frameworks}} + "btoa": "^1.2.1", "form-data": "^2.3.2", "@types/form-data": "^2.2.1", "url-parse": "^1.4.3", diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts index cf2b58ec9d9e..1ab37edc539c 100644 --- a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -18,7 +18,6 @@ import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ - export class StoreApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index e6b5b183e679..2479f3d6ca74 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -21,8 +21,9 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { for (let key in headers) { headers[key] = (headers[key] as Array).join("; "); } - + console.log("Received headers: ", headers) return resp.text().then((body: string) => { + console.log("Resp body ", body) return new ResponseContext(resp.status, headers, body) }); }); diff --git a/samples/client/petstore/typescript/builds/jquery/.gitignore b/samples/client/petstore/typescript/builds/jquery/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore b/samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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 +# This 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 diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION new file mode 100644 index 000000000000..717311e32e3c --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/README.md b/samples/client/petstore/typescript/builds/jquery/README.md new file mode 100644 index 000000000000..ea786ff2cf69 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/README.md @@ -0,0 +1 @@ +readme \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/TODO.md b/samples/client/petstore/typescript/builds/jquery/TODO.md new file mode 100644 index 000000000000..daf371f9e314 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/TODO.md @@ -0,0 +1,5 @@ + +Use qunit + https://github.com/ameshkov/node-qunit-puppeteer + +to run the tests locally using a headless chromium! +ADD https://github.com/chenglou/require-polyfill to make require work \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts new file mode 100644 index 000000000000..83904063a7dc --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -0,0 +1,584 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; + +/** + * no description + */ +export class PetApiRequestFactory extends BaseAPIRequestFactory { + + /** + * Add a new pet to the store + * @param body Pet object that needs to be added to the store + */ + public addPet(body: Pet, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling addPet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", "")); + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + + + // Path Params + const localVarPath = '/pet/findByStatus'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + if (status !== undefined) { + requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + + + // Path Params + const localVarPath = '/pet/findByTags'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + if (tags !== undefined) { + requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Update an existing pet + * @param body Pet object that needs to be added to the store + */ + public updatePet(body: Pet, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling updatePet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (name !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('name', name as any); + } + if (status !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('status', status as any); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (additionalMetadata !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + if (file !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('file', file.data, { "filename": file.name }); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + + + +export class PetApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public addPet(response: ResponseContext): void { + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public deletePet(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid pet value"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public findPetsByStatus(response: ResponseContext): Array { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid status value"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public findPetsByTags(response: ResponseContext): Array { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid tag value"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public getPetById(response: ResponseContext): Pet { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public updatePet(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Validation exception"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public updatePetWithForm(response: ResponseContext): void { + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public uploadFile(response: ResponseContext): ApiResponse { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + return body; + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts new file mode 100644 index 000000000000..55769fdc2491 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -0,0 +1,271 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { Order } from '../models/Order'; + +/** + * no description + */ +export class StoreApiRequestFactory extends BaseAPIRequestFactory { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): RequestContext { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/store/inventory'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Place an order for a pet + * @param body order placed for purchasing the pet + */ + public placeOrder(body: Order, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling placeOrder.'); + } + + + // Path Params + const localVarPath = '/store/order'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + +} + + + +export class StoreApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public deleteOrder(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public getInventory(response: ResponseContext): { [key: string]: number; } { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + return body; + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public getOrderById(response: ResponseContext): Order { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public placeOrder(response: ResponseContext): Order { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid Order"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts new file mode 100644 index 000000000000..b3040726a8f0 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -0,0 +1,517 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { User } from '../models/User'; + +/** + * no description + */ +export class UserApiRequestFactory extends BaseAPIRequestFactory { + + /** + * This can only be done by the logged in user. + * Create user + * @param body Created user object + */ + public createUser(body: User, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUser.'); + } + + + // Path Params + const localVarPath = '/user'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithArrayInput(body: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithArray'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithListInput(body: Array, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithList'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + + + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + + + // Path Params + const localVarPath = '/user/login'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + if (username !== undefined) { + requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string", "")); + } + if (password !== undefined) { + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): RequestContext { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/user/logout'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body: User, options?: Configuration): RequestContext { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('Required parameter body was null or undefined when calling updateUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + requestContext.setHeaderParam("Content-Type", "application/json"); + // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent + const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + +} + + + +export class UserApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public createUser(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public createUsersWithArrayInput(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public createUsersWithListInput(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public deleteUser(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public getUserByName(response: ResponseContext): User { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public loginUser(response: ResponseContext): string { + if (isCodeInRange("200", response.httpStatusCode)) { + const jsonBody = JSON.parse(response.body); + const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const jsonBody = JSON.parse(response.body); + const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + return body; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public logoutUser(response: ResponseContext): void { + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to + * @throws ApiException if the response code was not in [200, 299] + */ + public updateUser(response: ResponseContext): void { + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid user supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for incorrect api specification in petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts b/samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts new file mode 100644 index 000000000000..fe7ee3d15118 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/client/petstore/typescript/builds/jquery/apis/exception.ts b/samples/client/petstore/typescript/builds/jquery/apis/exception.ts new file mode 100644 index 000000000000..b76dca5aa4bc --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/apis/exception.ts @@ -0,0 +1,14 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ +export class ApiException extends Error { + public constructor(public code: number, public body: T) { + super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/auth/auth.ts b/samples/client/petstore/typescript/builds/jquery/auth/auth.ts new file mode 100644 index 000000000000..40a1e2e77bd8 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/auth/auth.ts @@ -0,0 +1,145 @@ +import {RequestContext} from '../http/http'; +// typings for btoa are incorrect +//@ts-ignore +import * as btoa from "btoa"; + +/** + * Base class for all authentication schemes. + * + */ +export abstract class SecurityAuthentication { + + public constructor(private name: string) { + + } + + /* + * + * @return returns the name of the security authentication as specified in OAI + */ + public getName(): string { + return this.name; + } + + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + public abstract applySecurityAuthentication(context: RequestContext): void; + +} + +/** + * Applies no authentication. + * + */ +export class NoAuthentication extends SecurityAuthentication { + + public constructor() { + super("_no_auth"); + } + + public applySecurityAuthentication(_context: RequestContext) { + + } +} + +/** + * Applies an api key to the request context. + * + */ +export class APIKeyAuthentication extends SecurityAuthentication { + + /** + * Configures this api key authentication with the necessary properties + * + * @param authName: name of this authentication scheme as specified in the swagger.json + * @param paramName: Parameter name used for the api key + * @param keyLocation: Parameter location, either query, header or cookie. + * @param apiKey: The api key to be used for every request + */ + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + if (this.keyLocation === "header") { + context.setHeaderParam(this.paramName, this.apiKey); + } else if (this.keyLocation === "cookie") { + context.addCookie(this.paramName, this.apiKey); + } else if (this.keyLocation === "query") { + context.setQueryParam(this.paramName, this.apiKey); + } + } +} + + +/** + * Applies basic http authentication to a request. + * + */ +export class HttpBasicAuthentication extends SecurityAuthentication { + + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in swagger json + * @param username username for http basic authentication + * @param password password for http basic authentication + */ + public constructor(authName: string, private username: string, private password: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + let comb = this.username + ":" + this.password; + context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + } +} + +// TODO: How to handle oauth2 authentication! +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + +export type AuthMethods = { + "api_key"?: APIKeyAuthentication, + "petstore_auth"?: OAuth2Authentication, +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } + +/** + * Creates the authentication methods from a swagger description. + * + */ +export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = { + } + + if (!conf) { + return authMethods; + } + + if (conf["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + } + + if (conf["petstore_auth"]) { + authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); + } + + return authMethods; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/configuration.ts b/samples/client/petstore/typescript/builds/jquery/configuration.ts new file mode 100644 index 000000000000..9bcc9c16eefc --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/configuration.ts @@ -0,0 +1,60 @@ +import {HttpLibrary} from './http/http'; +import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; +import {JQueryHttpLibrary} from "./http/jquery"; +import {ServerConfiguration, server1} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + +/** + * Inetrface with which a configuration object can be configured. + * + */ +export interface ConfigurationParameters { + /** + * Default server to use + */ + baseServer?: ServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ + httpApi?: HttpLibrary; + /** + * The middlewares which will be applied to requests and responses + */ + middleware?: Middleware[]; // middleware to apply before/after fetch requests + /** + * configures all middlewares using the promise api instead of observables (which Middleware uses) + */ + promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods + */ + authMethods?: AuthMethodsConfiguration +} + +export class Configuration { + + baseServer: ServerConfiguration; + httpApi: HttpLibrary; + middleware: Middleware[]; + authMethods: AuthMethods; + + /** + * Creates a new configuration object based on the given configuration. + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * @param conf particial configuration + */ + constructor(conf: ConfigurationParameters = {}) { + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; + this.httpApi = conf.httpApi || new JQueryHttpLibrary; // TODO: replace with window.fetch if available? + this.middleware = conf.middleware || []; + this.authMethods = configureAuthMethods(conf.authMethods); + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/git_push.sh b/samples/client/petstore/typescript/builds/jquery/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/git_push.sh @@ -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 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="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="Minor update" + 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 credential 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' + diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts new file mode 100644 index 000000000000..140f65c72e6a --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -0,0 +1,140 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; +// typings of url-parse are incorrect... +// @ts-ignore +import * as URLParse from "url-parse"; +import { Observable } from 'rxjs'; + +export * from './jquery'; + +/** + * Represents a HTTP Method. + */ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +/** + * Represents a http file which will be uploaded to a server. + */ +export interface HttpFile { + data: Blob; + name: string; +} + + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +/** + * Represents a HTTP request context + * + */ +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: string | FormData = ""; + private url: URLParse; + + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = URLParse(url, true); + } + + /* + * Returns the url set in the constructor including the query string + * + */ + public getUrl(): string { + return this.url.toString(); + } + + /** + * Replaces the url set in the constructor with this url. + * + */ + public setUrl(url: string) { + this.url = URLParse(url, true); + } + + + /** + * Sets the body of the http request either as a string or FormData + * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section + * 4.3 and this method throws an HttpException accordingly. + * + * @param body the body of the request + */ + public setBody(body: string | FormData) { + // HTTP-Spec 1.1 Section 4.3 + if (this.httpMethod === HttpMethod.GET) { + throw new HttpException("Body should not be included in GET-Requests!"); + } + + // TODO: other http methods + + // post is fine either formData or string + this.body = body; + + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): string | FormData { + return this.body; + } + + public setQueryParam(name: string, value: string) { + let queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + } + + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } +} + +export class ResponseContext { + + public constructor(public httpStatusCode: number, + public headers: { [key: string]: string }, public body: string) { + } + +} + +export interface HttpLibrary { + send(request: RequestContext): Observable; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts new file mode 100644 index 000000000000..fa82596128da --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -0,0 +1,76 @@ +import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import * as e6p from 'es6-promise' +import { from, Observable } from 'rxjs'; +e6p.polyfill(); +import * as $ from 'jquery'; +import * as FormData from "form-data"; +import { resolve } from 'dns'; + +export class JQueryHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + let headerParams = request.getHeaders() + + let requestOptions: any = { + url: request.getUrl(), + type: method, + headers: request.getHeaders(), + processData: false, + xhrFields: { withCredentials: true }, + data: body + }; + + if (request.getHeaders()['Content-Type']) { + requestOptions.contentType = headerParams['Content-Type']; + } + requestOptions.dataFilter = ((headerParams: { [key:string]: string}) => { + return (data: string, type: string) => { + if (headerParams["Accept"] == "application/json" && data == "") { + return "{}" + } else { + return data + } + } + })(headerParams); + + if (request.getHeaders()["Cookie"]) { + throw new HttpException("Setting the \"Cookie\"-Header field is blocked by every major browser when using jquery.ajax requests. Please switch to another library like fetch to enable this option"); + } + + if (body.constructor.name == "FormData") { + requestOptions.contentType = false; + } + const sentRequest = $.ajax(requestOptions); + + const resultPromise = new Promise((resolve, reject) => { + sentRequest.done((resp, _, jqXHR) => { + const headers = this.getResponseHeaders(jqXHR) + const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + resolve(result); + }) + sentRequest.fail((jqXHR: any) => { + const headers = this.getResponseHeaders(jqXHR) + const result = new ResponseContext(jqXHR.status, headers, jqXHR.responseText); + resolve(result); + }) + }) + return from(resultPromise); + } + + private getResponseHeaders(jqXHR: any): { [key: string]: string } { + const responseHeaders: { [key: string]: string } = {}; + var headers = jqXHR.getAllResponseHeaders(); + headers = headers.split("\n"); + headers.forEach(function (header: any) { + header = header.split(": "); + var key = header.shift(); + if (key.length == 0) return + // chrome60+ force lowercase, other browsers can be different + key = key.toLowerCase(); + responseHeaders[key] = header.join(": "); + }); + return responseHeaders + } +} diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/client/petstore/typescript/builds/jquery/index.ts new file mode 100644 index 000000000000..ca1c5ff976ff --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/index.ts @@ -0,0 +1,19 @@ +import * as http from './http/http'; +import * as auth from './auth/auth'; +import {Middleware, PromiseMiddleware} from './middleware'; +import * as models from './models/all'; +import { Configuration} from './configuration' +import * as apis from './types/PromiseAPI'; +import * as exceptions from './apis/exception'; + +export { + http, + + auth, + Middleware, + PromiseMiddleware, + models, + Configuration, + apis, + exceptions +}; \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/middleware.ts b/samples/client/petstore/typescript/builds/jquery/middleware.ts new file mode 100644 index 000000000000..f3b038ea17cb --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/middleware.ts @@ -0,0 +1,66 @@ +import {RequestContext, ResponseContext} from './http/http'; +import { Observable, from } from 'rxjs'; + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts new file mode 100644 index 000000000000..1e4383431b77 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts @@ -0,0 +1,51 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* Describes the result of uploading an image resource +*/ +export class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "number", + "format": "int32" + }, + { + "name": "type", + "baseName": "type", + "type": "string", + "format": "" + }, + { + "name": "message", + "baseName": "message", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ApiResponse.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/client/petstore/typescript/builds/jquery/models/Category.ts new file mode 100644 index 000000000000..69d6879fb9bd --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/Category.ts @@ -0,0 +1,44 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* A category for a pet +*/ +export class Category { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Category.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts new file mode 100644 index 000000000000..f6ca619bf10b --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -0,0 +1,159 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + +import { ApiResponse } from './ApiResponse'; +import { Category } from './Category'; +import { Order , OrderStatusEnum } from './Order'; +import { Pet , PetStatusEnum } from './Pet'; +import { Tag } from './Tag'; +import { User } from './User'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: Set = new Set([ + "OrderStatusEnum", + "PetStatusEnum", +]); + +let typeMap: {[index: string]: any} = { + "ApiResponse": ApiResponse, + "Category": Category, + "Order": Order, + "Pet": Pet, + "Tag": Tag, + "User": User, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap.has(expectedType)) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string, format: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } + } else { + if (enumsMap.has(type)) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); + } + return instance; + } + } + + public static deserialize(data: any, type: string, format: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap.has(type)) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); + } + return instance; + } + } +} diff --git a/samples/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/client/petstore/typescript/builds/jquery/models/Order.ts new file mode 100644 index 000000000000..0ef6a1dbef14 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/Order.ts @@ -0,0 +1,78 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* An order for a pets from the pet store +*/ +export class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; + /** + * Order Status + */ + 'status'?: OrderStatusEnum; + 'complete'?: boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number", + "format": "int64" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number", + "format": "int32" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date", + "format": "date-time" + }, + { + "name": "status", + "baseName": "status", + "type": "OrderStatusEnum", + "format": "" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Order.attributeTypeMap; + } + + public constructor() { + } +} + + +export type OrderStatusEnum = "placed" | "approved" | "delivered" ; + diff --git a/samples/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/client/petstore/typescript/builds/jquery/models/Pet.ts new file mode 100644 index 000000000000..cf45a4341f34 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/Pet.ts @@ -0,0 +1,80 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { Category } from './Category'; +import { Tag } from './Tag'; + +/** +* A pet for sale in the pet store +*/ +export class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; + /** + * pet status in the store + */ + 'status'?: PetStatusEnum; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "category", + "baseName": "category", + "type": "Category", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array", + "format": "" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "PetStatusEnum", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Pet.attributeTypeMap; + } + + public constructor() { + } +} + + +export type PetStatusEnum = "available" | "pending" | "sold" ; + diff --git a/samples/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/client/petstore/typescript/builds/jquery/models/Tag.ts new file mode 100644 index 000000000000..53576de1f9d3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/Tag.ts @@ -0,0 +1,44 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* A tag for a pet +*/ +export class Tag { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Tag.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/jquery/models/User.ts b/samples/client/petstore/typescript/builds/jquery/models/User.ts new file mode 100644 index 000000000000..71276892aa0b --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/User.ts @@ -0,0 +1,89 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* A User who is purchasing from the pet store +*/ +export class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; + /** + * User Status + */ + 'userStatus'?: number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "username", + "baseName": "username", + "type": "string", + "format": "" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string", + "format": "" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string", + "format": "" + }, + { + "name": "email", + "baseName": "email", + "type": "string", + "format": "" + }, + { + "name": "password", + "baseName": "password", + "type": "string", + "format": "" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string", + "format": "" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return User.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/jquery/models/all.ts b/samples/client/petstore/typescript/builds/jquery/models/all.ts new file mode 100644 index 000000000000..2edba7f0bd56 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/models/all.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse' +export * from './Category' +export * from './Order' +export * from './Pet' +export * from './Tag' +export * from './User' diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/client/petstore/typescript/builds/jquery/package-lock.json new file mode 100644 index 000000000000..81d989625da1 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/package-lock.json @@ -0,0 +1,241 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/jquery": { + "version": "3.3.29", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", + "integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==", + "requires": { + "@types/sizzle": "*" + } + }, + "@types/node": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" + }, + "@types/rx": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/sizzle": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", + "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "es6-promise": { + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "jquery": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", + "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "querystringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "rxjs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", + "requires": { + "tslib": "^1.9.0" + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + } + } +} diff --git a/samples/client/petstore/typescript/builds/jquery/package.json b/samples/client/petstore/typescript/builds/jquery/package.json new file mode 100644 index 000000000000..34f8c7975f3c --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/package.json @@ -0,0 +1,34 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "description": "OpenAPI client for ", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator", + "" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "es6-promise": "^4.2.4", + "@types/jquery": "^3.3.29", + "jquery": "^3.4.1", + "btoa": "^1.2.1", + "form-data": "^2.3.2", + "@types/form-data": "^2.2.1", + "url-parse": "^1.4.3", + "rxjs": "^6.4.0", + "@types/rx": "^4.1.1" + }, + "devDependencies": { + "typescript": "^2.9.2" + } +} diff --git a/samples/client/petstore/typescript/builds/jquery/servers.ts b/samples/client/petstore/typescript/builds/jquery/servers.ts new file mode 100644 index 000000000000..2819fdbe4274 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/servers.ts @@ -0,0 +1,55 @@ +import {RequestContext, HttpMethod} from './http/http'; + +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration { + + public constructor(private url: string, private variableConfiguration: T) { + } + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + for (const key in variableConfiguration) { + const val = variableConfiguration[key] + // We know that val isn't undefined here - hopefully + if (val !== undefined) { + this.variableConfiguration[key] = val as T[Extract]; + } + } + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + } + return replacedUrl + } + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.getUrl() + endpoint, httpMethod); + } +} + +export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) diff --git a/samples/client/petstore/typescript/builds/jquery/tsconfig.json b/samples/client/petstore/typescript/builds/jquery/tsconfig.json new file mode 100644 index 000000000000..142f3fa631a3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "module": "commonjs", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "dist", + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts new file mode 100644 index 000000000000..079853bb913a --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts @@ -0,0 +1,540 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of } from 'rxjs'; +import {mergeMap, map} from 'rxjs/operators'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class ObservablePetApi { + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } + + /** + * Add a new pet to the store + * @param body Pet object that needs to be added to the store + */ + public addPet(body: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.addPet(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); + })); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deletePet(petId, apiKey, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); + })); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { + const requestContext = this.requestFactory.findPetsByStatus(status, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); + })); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Observable> { + const requestContext = this.requestFactory.findPetsByTags(tags, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); + })); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Observable { + const requestContext = this.requestFactory.getPetById(petId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); + })); + } + + /** + * Update an existing pet + * @param body Pet object that needs to be added to the store + */ + public updatePet(body: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePet(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); + })); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); + })); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { + const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); + })); + } + + +} + + + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class ObservableStoreApi { + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deleteOrder(orderId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); + })); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { + const requestContext = this.requestFactory.getInventory(options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); + })); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Observable { + const requestContext = this.requestFactory.getOrderById(orderId, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); + })); + } + + /** + * Place an order for a pet + * @param body order placed for purchasing the pet + */ + public placeOrder(body: Order, options?: Configuration): Observable { + const requestContext = this.requestFactory.placeOrder(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); + })); + } + + +} + + + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class ObservableUserApi { + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param body Created user object + */ + public createUser(body: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUser(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithArrayInput(body: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithArrayInput(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithListInput(body: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithListInput(body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.deleteUser(username, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); + })); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.getUserByName(username, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); + })); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Observable { + const requestContext = this.requestFactory.loginUser(username, password, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); + })); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Observable { + const requestContext = this.requestFactory.logoutUser(options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.updateUser(username, body, options); + + // build promise chain + let middlewarePreObservable = of(requestContext); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); + })); + } + + +} + + + diff --git a/samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts b/samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts new file mode 100644 index 000000000000..9aabd2472684 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts @@ -0,0 +1,252 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; +import { ObservablePetApi } from './ObservableAPI'; + + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class PromisePetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param body Pet object that needs to be added to the store + */ + public addPet(body: Pet, options?: Configuration): Promise { + const result = this.api.addPet(body, options); + return result.toPromise(); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + const result = this.api.deletePet(petId, apiKey, options); + return result.toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { + const result = this.api.findPetsByStatus(status, options); + return result.toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Promise> { + const result = this.api.findPetsByTags(tags, options); + return result.toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Promise { + const result = this.api.getPetById(petId, options); + return result.toPromise(); + } + + /** + * Update an existing pet + * @param body Pet object that needs to be added to the store + */ + public updatePet(body: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(body, options); + return result.toPromise(); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Promise { + const result = this.api.updatePetWithForm(petId, name, status, options); + return result.toPromise(); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + const result = this.api.uploadFile(petId, additionalMetadata, file, options); + return result.toPromise(); + } + + +} + + + +import { ObservableStoreApi } from './ObservableAPI'; + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class PromiseStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Promise { + const result = this.api.deleteOrder(orderId, options); + return result.toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { + const result = this.api.getInventory(options); + return result.toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Promise { + const result = this.api.getOrderById(orderId, options); + return result.toPromise(); + } + + /** + * Place an order for a pet + * @param body order placed for purchasing the pet + */ + public placeOrder(body: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(body, options); + return result.toPromise(); + } + + +} + + + +import { ObservableUserApi } from './ObservableAPI'; + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class PromiseUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param body Created user object + */ + public createUser(body: User, options?: Configuration): Promise { + const result = this.api.createUser(body, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithArrayInput(body: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(body, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param body List of user object + */ + public createUsersWithListInput(body: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(body, options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Promise { + const result = this.api.deleteUser(username, options); + return result.toPromise(); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Promise { + const result = this.api.getUserByName(username, options); + return result.toPromise(); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Promise { + const result = this.api.loginUser(username, password, options); + return result.toPromise(); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Promise { + const result = this.api.logoutUser(options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, body, options); + return result.toPromise(); + } + + +} + + + diff --git a/samples/client/petstore/typescript/builds/jquery/util.ts b/samples/client/petstore/typescript/builds/jquery/util.ts new file mode 100644 index 000000000000..d1888434535c --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/util.ts @@ -0,0 +1,28 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/.gitignore b/samples/client/petstore/typescript/tests/jquery/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/client/petstore/typescript/tests/jquery/index.html b/samples/client/petstore/typescript/tests/jquery/index.html new file mode 100644 index 000000000000..702d5739ce34 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/index.html @@ -0,0 +1,15 @@ + + + + + + QUnit Example + + + +
+
+ + + + \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts b/samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts new file mode 100644 index 000000000000..083e2057f8c6 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts @@ -0,0 +1 @@ +declare module 'node-qunit-puppeteer'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json new file mode 100644 index 000000000000..a9e4f1f3dec3 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -0,0 +1,3463 @@ +{ + "name": "typescript-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", + "dev": true + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + }, + "dependencies": { + "@types/node": { + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" + } + } + }, + "@types/jsdom": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-12.2.3.tgz", + "integrity": "sha512-CxYWGFsBs0VZ/lU9zxfWk7zYfOlQQuSs5yzk34KW/vQQJGE8OGOYxJnqj9kGHE1SBZGVJvhXs1TafIpZL8RvXw==", + "requires": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^4.0.0" + }, + "dependencies": { + "parse5": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", + "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==" + } + } + }, + "@types/mocha": { + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", + "dev": true + }, + "@types/node": { + "version": "8.10.48", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.48.tgz", + "integrity": "sha512-c35YEBTkL4rzXY2ucpSKy+UYHjUBIIkuJbWYbsGIrKLEWU5dgJMmLkkIb3qeC3O3Tpb1ZQCwecscvJTDjDjkRw==" + }, + "@types/qunit": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.9.0.tgz", + "integrity": "sha512-Hx34HZmTJKRay+x3sFdEK62I8Z8YSWYg+rAlNr4M+AbwvNUJYxTTmWEH4a8B9ZN+Fl61awFrw+oRicWLFVugvQ==" + }, + "@types/rewire": { + "version": "2.5.28", + "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", + "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" + }, + "@types/rx": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/tough-cookie": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", + "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==" + }, + "abab": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", + "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==" + }, + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + }, + "acorn-globals": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.2.tgz", + "integrity": "sha512-BbzvZhVtZP+Bs1J1HcwrQe8ycfO0wStkSGxuul3He3GkHOIZ6eTqOkPuw9IP1X3+IkOo4wiJmwkobzXYz4wewQ==", + "requires": { + "acorn": "^6.0.1", + "acorn-walk": "^6.0.1" + }, + "dependencies": { + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" + } + } + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" + } + } + }, + "acorn-walk": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", + "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==" + }, + "agent-base": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "requires": { + "es6-promisify": "^5.0.0" + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" + }, + "ansi-escapes": { + "version": "3.1.0", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", + "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browser-process-hrtime": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", + "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "requires": { + "callsites": "^0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==" + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "cssom": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz", + "integrity": "sha512-DtUeseGk9/GBW0hl0vVPpU22iHL6YB5BUX7ml1hB+GMpo0NX5G4voX3kdWiMSEguFtcW3Vh3djqNF4aIe6ne0A==" + }, + "cssstyle": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.2.2.tgz", + "integrity": "sha512-43wY3kl1CVQSvL7wUY1qXkxVGkStjpkDmVjiIKX8R97uhajy8Bybay78uOtqvh7Q5GK75dNPfW0geWjE6qQQow==", + "requires": { + "cssom": "0.3.x" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "data-urls": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.1.0.tgz", + "integrity": "sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ==", + "requires": { + "abab": "^2.0.0", + "whatwg-mimetype": "^2.2.0", + "whatwg-url": "^7.0.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "requires": { + "esutils": "^2.0.2" + } + }, + "domexception": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", + "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", + "requires": { + "webidl-conversions": "^4.0.2" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "enhanced-resolve": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", + "integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "tapable": "^1.0.0" + } + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "dev": true, + "requires": { + "prr": "~1.0.1" + } + }, + "es6-promise": { + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "requires": { + "es6-promise": "^4.0.3" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "escodegen": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.1.tgz", + "integrity": "sha512-JwiqFD9KdGVVpeuRa68yU3zZnBEOcPs0nKW7wZzXky8Z7tffdYUHbe11bPCV5jYlK6DVdKLWLm0f5I/QlL0Kmw==", + "requires": { + "esprima": "^3.1.3", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true + } + } + }, + "eslint": { + "version": "4.19.1", + "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "requires": { + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", + "table": "4.0.2", + "text-table": "~0.2.0" + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" + }, + "espree": { + "version": "3.5.4", + "resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "external-editor": { + "version": "2.2.0", + "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "requires": { + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "requires": { + "pend": "~1.2.0" + } + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", + "write": "^0.2.1" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", + "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + } + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "html-encoding-sniffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", + "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", + "requires": { + "whatwg-encoding": "^1.0.1" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "requires": { + "agent-base": "^4.1.0", + "debug": "^3.1.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==" + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "js-reporters": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/js-reporters/-/js-reporters-1.2.1.tgz", + "integrity": "sha1-+IxgjjJKM3OpW8xFrTBeXJecRZs=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "jsdom": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-15.0.0.tgz", + "integrity": "sha512-rJnHm7CHyIj4tDyz9VaCt0f0P0nEh/wEmMfwp9mMixy+L/r8OW/BNcgmIlfZuBBnVQS3eRBpvd/qM3R7vr7e3A==", + "requires": { + "abab": "^2.0.0", + "acorn": "^6.0.4", + "acorn-globals": "^4.3.0", + "array-equal": "^1.0.0", + "cssom": "^0.3.4", + "cssstyle": "^1.1.1", + "data-urls": "^1.1.0", + "domexception": "^1.0.1", + "escodegen": "^1.11.0", + "html-encoding-sniffer": "^1.0.2", + "nwsapi": "^2.1.3", + "parse5": "5.1.0", + "pn": "^1.1.0", + "request": "^2.88.0", + "request-promise-native": "^1.0.5", + "saxes": "^3.1.9", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.5.0", + "w3c-hr-time": "^1.0.1", + "w3c-xmlserializer": "^1.1.2", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.5", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^7.0.0", + "ws": "^6.1.2", + "xml-name-validator": "^3.0.0" + }, + "dependencies": { + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" + } + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==" + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", + "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" + }, + "mime-db": { + "version": "1.36.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + }, + "mime-types": { + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "requires": { + "mime-db": "~1.36.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" + }, + "node-qunit-puppeteer": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/node-qunit-puppeteer/-/node-qunit-puppeteer-1.0.12.tgz", + "integrity": "sha512-3nIXzI11MgTvuY772J6m0XRxkgFj1/dzJ8UUuE+S8AiUhOfz/gzs/IPjmjZaA4Fgm3cRuQZViuudQXZoiNDgvQ==", + "requires": { + "colors": "^1.3.2", + "puppeteer": "^1.9.0" + } + }, + "node-watch": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.6.0.tgz", + "integrity": "sha512-XAgTL05z75ptd7JSVejH1a2Dm1zmXYhuDr9l230Qk6Z7/7GPcnAs/UyJJ4ggsXSvWil8iOzwQLW0zuGUvHpG8g==" + }, + "nwsapi": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", + "integrity": "sha512-iGfd9Y6SFdTNldEy2L0GUhcarIutFmk+MPWIn9dmj8NMIup03G08uUF2KGbbmv/Ux4RT0VZJoP/sVbWA6d/VIw==" + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" + }, + "pn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", + "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==" + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", + "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==" + }, + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "puppeteer": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz", + "integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==", + "requires": { + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^2.2.1", + "mime": "^2.0.3", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "qunit": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/qunit/-/qunit-2.9.2.tgz", + "integrity": "sha512-wTOYHnioWHcx5wa85Wl15IE7D6zTZe2CQlsodS14yj7s2FZ3MviRnQluspBZsueIDEO7doiuzKlv05yfky1R7w==", + "requires": { + "commander": "2.12.2", + "js-reporters": "1.2.1", + "minimatch": "3.0.4", + "node-watch": "0.6.0", + "resolve": "1.9.0" + }, + "dependencies": { + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==" + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexpp": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + } + } + }, + "request-promise-core": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", + "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "requires": { + "lodash": "^4.17.11" + } + }, + "request-promise-native": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz", + "integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==", + "requires": { + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==" + }, + "resolve": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz", + "integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=" + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "rewire": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/rewire/-/rewire-4.0.1.tgz", + "integrity": "sha512-+7RQ/BYwTieHVXetpKhT11UbfF6v1kGhKFrtZN7UDL2PybMsSt/rpLWeEUGF5Ndsl1D5BxiCB14VDJyoX+noYw==", + "requires": { + "eslint": "^4.19.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "requires": { + "is-promise": "^2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=" + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "requires": { + "rx-lite": "*" + } + }, + "rxjs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", + "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saxes": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.9.tgz", + "integrity": "sha512-FZeKhJglhJHk7eWG5YM0z46VHmI3KJpMBAQm3xa9meDvd+wevB5GuBB0wc0exPInZiBBHqi00DbS8AcvCGCFMw==", + "requires": { + "xmlchars": "^1.3.1" + } + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "requires": { + "source-map": "^0.5.6" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + } + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "symbol-tree": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", + "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=" + }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "requires": { + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + }, + "tapable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "requires": { + "punycode": "^2.1.0" + } + }, + "ts-loader": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-4.3.1.tgz", + "integrity": "sha512-ra304bebnyxd9nIJoKjQoeQLOENqrDG7vfppS+DkCnqOEv29GuiiWMvgebuCqFko0AkMFpoubRLeFM7YmlkL3w==", + "dev": true, + "requires": { + "chalk": "^2.3.0", + "enhanced-resolve": "^4.0.0", + "loader-utils": "^1.0.2", + "micromatch": "^3.1.4", + "semver": "^5.0.1" + } + }, + "ts-node": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", + "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", + "requires": { + "arrify": "^1.0.0", + "chalk": "^2.0.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.0", + "tsconfig": "^6.0.0", + "v8flags": "^3.0.0", + "yn": "^2.0.0" + } + }, + "ts-petstore-client": { + "version": "file:../../builds/jquery", + "requires": { + "@types/form-data": "^2.2.1", + "@types/jquery": "^3.3.29", + "@types/rx": "^4.1.1", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", + "form-data": "^2.3.2", + "jquery": "^3.4.1", + "rxjs": "^6.4.0", + "url-parse": "^1.4.3" + }, + "dependencies": { + "@types/form-data": { + "version": "2.2.1", + "bundled": true, + "requires": { + "@types/node": "*" + } + }, + "@types/jquery": { + "version": "3.3.29", + "bundled": true, + "requires": { + "@types/sizzle": "*" + } + }, + "@types/node": { + "version": "12.0.0", + "bundled": true + }, + "@types/rx": { + "version": "4.1.1", + "bundled": true, + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "bundled": true + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "bundled": true, + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.6", + "bundled": true, + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "bundled": true, + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "bundled": true, + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/sizzle": { + "version": "2.3.2", + "bundled": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true + }, + "btoa": { + "version": "1.2.1", + "bundled": true + }, + "combined-stream": { + "version": "1.0.7", + "bundled": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "es6-promise": { + "version": "4.2.6", + "bundled": true + }, + "form-data": { + "version": "2.3.3", + "bundled": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "jquery": { + "version": "3.4.1", + "bundled": true + }, + "mime-db": { + "version": "1.40.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.24", + "bundled": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "querystringify": { + "version": "2.1.1", + "bundled": true + }, + "requires-port": { + "version": "1.0.0", + "bundled": true + }, + "rxjs": { + "version": "6.5.1", + "bundled": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "tslib": { + "version": "1.9.3", + "bundled": true + }, + "typescript": { + "version": "2.9.2", + "bundled": true + }, + "url-parse": { + "version": "1.4.7", + "bundled": true, + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + } + } + }, + "tsconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", + "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", + "requires": { + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "v8flags": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", + "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "w3c-hr-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", + "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "requires": { + "browser-process-hrtime": "^0.1.2" + } + }, + "w3c-xmlserializer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-1.1.2.tgz", + "integrity": "sha512-p10l/ayESzrBMYWRID6xbuCKh2Fp77+sA0doRuGn4tTIMrrZVeqfpKjXHY+oDh3K4nLdPgNwMTVP6Vp4pvqbNg==", + "requires": { + "domexception": "^1.0.1", + "webidl-conversions": "^4.0.2", + "xml-name-validator": "^3.0.0" + } + }, + "webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" + }, + "whatwg-encoding": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", + "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", + "requires": { + "iconv-lite": "0.4.24" + } + }, + "whatwg-mimetype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", + "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" + }, + "whatwg-url": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.0.0.tgz", + "integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==", + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "requires": { + "mkdirp": "^0.5.1" + } + }, + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" + }, + "xmlchars": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-1.3.1.tgz", + "integrity": "sha512-tGkGJkN8XqCod7OT+EvGYK5Z4SfDQGD30zAa58OcnAa0RRWgzUEK72tkXhsX1FZd+rgnhRxFtmO+ihkp8LHSkw==" + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "requires": { + "fd-slicer": "~1.0.1" + } + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=" + } + } +} diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/client/petstore/typescript/tests/jquery/package.json new file mode 100644 index 000000000000..bddd4b85afbf --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/package.json @@ -0,0 +1,41 @@ +{ + "private": true, + "dependencies": { + "@types/form-data": "^2.2.1", + "@types/jsdom": "^12.2.3", + "@types/qunit": "^2.9.0", + "@types/rewire": "^2.5.28", + "@types/rx": "^4.1.1", + "form-data": "^2.3.2", + "jsdom": "^15.0.0", + "node-qunit-puppeteer": "^1.0.12", + "qunit": "^2.9.2", + "requirejs": "^2.3.6", + "rewire": "^4.0.1", + "rxjs": "^6.4.0", + "ts-node": "^3.3.0", + "ts-petstore-client": "file:../../builds/jquery" + }, + "scripts": { + "prepublish": "npm install ../../builds/jquery && npm run build", + "test": "node ./dist/test-runner.js", + "build": "tsc" + }, + "devDependencies": { + "@types/chai": "^4.0.1", + "@types/mocha": "^2.2.41", + "@types/node": "^8.10.48", + "chai": "^4.1.0", + "mocha": "^5.2.0", + "ts-loader": "^4.3.1", + "typescript": "^2.4.1" + }, + "name": "typescript-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/client/petstore/typescript/tests/jquery/pom.xml b/samples/client/petstore/typescript/tests/jquery/pom.xml new file mode 100644 index 000000000000..d352f8131e11 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + org.openapitools + TypeScriptPestoreClientTests + pom + 1.0-SNAPSHOT + TS Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/client/petstore/typescript/tests/jquery/require1k.min.js b/samples/client/petstore/typescript/tests/jquery/require1k.min.js new file mode 100644 index 000000000000..d03349015e12 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/require1k.min.js @@ -0,0 +1 @@ +R=function(e,n,v1){function t(e,o,u,a){if(e.g)return o(e.e,e);var c=e.g=e.l,f=new XMLHttpRequest;f.onload=function(i,l){function s(){l--||o(n,e)}200==f.status||e.t?(i=[],(e.t=e.t||f.response).replace(/(?:^|[^\w\$_.])require\s*\(\s*["']([^"']*)["']\s*\)/g,function(e,n){i.push(n)}),l=i.length,i.map(function(o){t(r(e.l,o),s,"."!=o[0]?c+"/../":n,o)}),s()):u?t(e.n=r(u+="../",a),o,u,a):(e.e=f,o(f,e))},e.t?f.onload():(f.open("GET",c,!0),f.send())}function r(e,n,t){if(e.e)throw e.e;return n?(f.href=e,i.href="."!=n[0]?"./node_modules/"+n:n,t=i.href+".js",f.href="",u[t]=u[t]||{l:t}):e.n?r(e.n):(e[c]||(e.f||a("(function(require,"+c+",module){"+e.t+"\n})//# sourceURL="+e.l))(function(n){return r(r(e.l,n))},e[c]={},e),e[c])}function o(e,n){t(e.call?{l:"",t:""+e,f:e}:r("",e),function(t,o){try{e=r(o)}catch(u){t=u}n&&n(t,e)})}var u={},a=eval,c="createElement",f=e[c]("base"),i=e[c]("a");return e.head.appendChild(f),c=e.querySelector("script[data-main]"),c&&o(c.dataset.main),c="exports",o}(document); \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/test-runner.ts b/samples/client/petstore/typescript/tests/jquery/test-runner.ts new file mode 100644 index 000000000000..7a08e997835c --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/test-runner.ts @@ -0,0 +1,29 @@ +import * as path from 'path' +import * as process from 'process' + +import { runQunitPuppeteer, printResultSummary, printFailedTests } from 'node-qunit-puppeteer'; + +const qunitArgs = { + // Path to qunit tests suite + targetUrl: `file://${path.join(__dirname, '../index.html')}`, + // (optional, 30000 by default) global timeout for the tests suite + timeout: 10000, + // (optional, false by default) should the browser console be redirected or not + redirectConsole: true, + puppeteerArgs: [ '--disable-web-security'] +}; + +runQunitPuppeteer(qunitArgs) + .then((result: any) => { + printResultSummary(result, console); + + if (result.stats.failed > 0) { + printFailedTests(result, console); + // other action(s) on failed tests + process.exit(1) + } + }) + .catch((ex: any) => { + console.error(ex); + process.exit(2) + }); \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts new file mode 100644 index 000000000000..89cf2b8275de --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts @@ -0,0 +1,121 @@ +declare var QUnit: any; + +import * as petstore from 'ts-petstore-client' + +const configuration = new petstore.Configuration() +const petApi = new petstore.apis.PromisePetApi(configuration) + +const tag = new petstore.models.Tag(); +tag.name = "tag1" +tag.id = Math.floor(Math.random() * 100000) + +const pet = new petstore.models.Pet() +pet.id = Math.floor(Math.random() * 100000) +pet.name = "PetName" +pet.photoUrls = [] +pet.status = 'available' +pet.tags = [ tag ] +pet.category = undefined + +QUnit.module("PetApi") + +QUnit.test("addPet", (assert: any) => { + return petApi.addPet(pet).then(() => { + return petApi.getPetById(pet.id) + }).then((createdPet: petstore.models.Pet) => { + assert.deepEqual(createdPet, pet); + }) +}) + +QUnit.test("deletePet", (assert: any) => { + return petApi.addPet(pet).then(() => { + return petApi.deletePet(pet.id) + }).then(() => { + return petApi.getPetById(pet.id) + }).then((pet: petstore.models.Pet) => { + throw new Error("Pet with id " + pet.id + " was not deleted!"); + }).catch((err: any) => { + // pet does not exist + if (err.code && err.code == 404) { + assert.ok(true, "404'd on getPet after deletion - all good.") + return; + } else { + throw err; + } + }) +}) + +QUnit.test("findPetsByStatus", (assert: any) => { + return petApi.addPet(pet).then(() => { + return petApi.findPetsByStatus(["available"]) + }).then((pets: petstore.models.Pet[]) => { + assert.ok(pets.length >= 1, "Found at least one pet."); + }) +}) + +// bugged on server side! Code 500 +/* QUnit.test("findPetsByTag", (done) => { + petApi.addPet(pet).then(() => { + return petApi.findPetsByTags([tag.name]) + }).then((pets: Pet[]) => { + expect(pets.length).to.be.at.least(1); + done(); + }).catch((err) => { + done(err); + }) +})*/ + +QUnit.test("getPetById", (assert: any) => { + return petApi.addPet(pet).then(() => { + return petApi.getPetById(pet.id) + }).then((returnedPet: petstore.models.Pet) => { + assert.deepEqual(returnedPet, pet); + }) +}) + +QUnit.test("updatePet", (assert: any) => { + const oldName = pet.name + const updatedName = "updated name"; + return petApi.addPet(pet).then(() => { + pet.name = updatedName + return petApi.updatePet(pet).then(() => { + pet.name = oldName; + }).catch((err) => { + pet.name = oldName + throw err; + }); + }).then(() => { + return petApi.getPetById(pet.id); + }).then((returnedPet: petstore.models.Pet) => { + assert.equal(returnedPet.id, pet.id) + assert.equal(returnedPet.name, updatedName); + }) +}) + +// not supported by online swagger api? +/* QUnit.test("updatePetWithForm", (done) => { + const updatedName = "updated name"; + petApi.addPet(pet).then(() => { + return petApi.updatePetWithForm(pet.id, updatedName) + }).then(() => { + return petApi.getPetById(pet.id) + }).then((returnedPet: Pet) => { + expect(returnedPet.id).to.equal(pet.id) + expect(returnedPet.name).to.equal(updatedName); + done() + }).catch((err) => { + done(err) + }) +})*/ + +/** not easily possible? +QUnit.test("uploadFile", (done) => { + const image = fs.readFileSync(__dirname + "/pet.png") + petApi.uploadFile(pet.id, "Metadata", { name: "pet.png", data: image}).then((response: any) => { + expect(response.code).to.be.gte(200).and.lt(300); + expect(response.message).to.contain("pet.png"); + done(); + }).catch((err) => { + done(err); + }) +})*/ diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/pet.png b/samples/client/petstore/typescript/tests/jquery/test/api/pet.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a9c49163db88f92e798e1c2aa4920ee6190829 GIT binary patch literal 1122 zcmV-o1fBbdP)Pv>k;Jhr>-0WM zqfHxc(XJkZAh2f0;gAyF_nm#aN+~I&5JCvSdygNrRv`otbzNtS>AFs9t+kd?a?T%* z)A#7L)>>=MIfSsT>+N=1*LB-A5GbWmN`2o8Avot!O8oc*!M^V~=NO~+exB!Pnm~|q zCL*nM&UxQ=B9c;K=bS%s{33&8S(arvpU=y(AOmad>+35KS!W+5c8t}76wlv2uV+qP|sF_u#B{a1pN5)la@o}qyrW6U{w@3(CWA;cI_WK=ch zTuQ06g5V1dV~k2Eob!F(rIe4d06nGTy@zw=d0y8QOr;beGREZlLO(rs6>Zz5lu}AD z#-J6{#4&&_%i_I9m&F)kjGS{sopWxu&-yUNXrAY;>ku*$-1i-^LvD1y^?IG>IfSrn zTT1CMl#~*%ng*W;VCtN+F@}g>%~sOu^?E*^=Xpl>>$;|t5H%4!;tC;-GkAZ0AIH%- zmve@NODWBim&*msb-7&N&YUwW)O3fowbp-TugAj{=f)Uo?KqCZFuc6H48t%CgSGbgGGL5R z2tf#e*?{wiw>1$Fp?dHo5fPDd?sPi6y}f}zYmJf|5CFHSeBQE5_0x-rt=4g|TbKZ3w z4AX`Ox)hbvTKD(moa_4@lt}J?0NP0@@loIR2p?%ddfd9`ENgAob#SLK#yNL**Z(De zENB^H4DP=M*EkTn5CYE=M2%C2{q?B^_zuSqpi;_O3sA-w^u-N>#}AIQ2>yl67$fH# zo-}Aq?6}178_@09({S!_n_SH&_zh5eBkt=b(0^-yCcu4wkgc_N79w7N z!cJ}f;iA*&gpNhLz-5fVR89SMq5gJJ*L9c>=p(c{+OkRUf6yNUecxly!!t;t$@0BJ oenc<~0|qjrfO8I?vH!RJ0MkcqZO@AHAOHXW07*qoM6N<$f;dkN^Z)<= literal 0 HcmV?d00001 diff --git a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts new file mode 100644 index 000000000000..d2f80876bb1a --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts @@ -0,0 +1,85 @@ +declare var QUnit: any; + +import * as petstore from "ts-petstore-client"; + +import * as FormData from "form-data"; + +let libs: { [key: string]: petstore.http.HttpLibrary } = { + "jquery": new petstore.http.JQueryHttpLibrary() +} + + +for (let libName in libs) { + let lib = libs[libName]; + + QUnit.module(libName); + QUnit.test("GET-Request", (assert: any) => { + let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + return new Promise((resolve, reject) => { + lib.send(requestContext).subscribe((resp: petstore.http.ResponseContext) => { + assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); + let body = JSON.parse(resp.body); + assert.ok(body["headers"]); + assert.equal(body["headers"]["X-Test-Token"],"Test-Token"); + resolve() + }, + (e: any) => { + console.error(e) + assert.ok(false, "Error: " + JSON.stringify(e)) + reject(e) + }) + }); + }) + + QUnit.test("POST-Request", (assert: any) => { + let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); + requestContext.setHeaderParam("X-Test-Token", "Test-Token"); + let formData: FormData = new FormData() + formData.append("test", "test2"); + formData.append("testFile", new Blob(["abc"], { + type: 'text/plain' + }), "fileName.json"); + + requestContext.setBody(formData); + return new Promise((resolve, reject) => { + lib.send(requestContext).subscribe( + (resp: petstore.http.ResponseContext) => { + assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); + let body = JSON.parse(resp.body); + assert.ok(body["headers"]); + assert.equal(body["headers"]["X-Test-Token"], "Test-Token"); + assert.equal(body["files"]["testFile"], "abc"); + assert.equal(body["form"]["test"], "test2"); + resolve(); + }, + (e: any) => { + console.error(e) + assert.ok(false, "Error: " + JSON.stringify(e)) + reject(e); + }) + }); + }); + + QUnit.test("Cookie-Test", (assert: any) => { + let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); + requestContext.addCookie("test", "test2"); + return new Promise((resolve, reject) => { + try { + lib.send(requestContext).subscribe( + (resp: petstore.http.ResponseContext) => { + assert.ok(false, "Expected this request to fail!") + reject("Successful request with Cookie Header!") + }, + (e: any) => { + console.error(e) + assert.ok(false, "Request with cookie header field was sent and failed.") + reject(e); + }) + } catch (e) { + assert.equal(e.message, "Setting the \"Cookie\"-Header field is blocked by every major browser when using jquery.ajax requests. Please switch to another library like fetch to enable this option", "Received error when trying to send request containing Cookie Header with jquery"); + resolve(); + } + }); + }); +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/tests.ts b/samples/client/petstore/typescript/tests/jquery/tests.ts new file mode 100644 index 000000000000..502f8c0dbbfc --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/tests.ts @@ -0,0 +1,9 @@ +declare var QUnit: any; + +QUnit.test( "hello test", function( assert: any ) { + let random = Math.random() + assert.ok( random.toString() == "" + random, "Passed!" ); +}); + +import './test/http/jquery.test' +import './test/api/PetApi.test' \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/tsconfig.json b/samples/client/petstore/typescript/tests/jquery/tsconfig.json new file mode 100644 index 000000000000..4596f6e40bcf --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha", + "node" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript/tests/jquery/weback.config.js b/samples/client/petstore/typescript/tests/jquery/weback.config.js new file mode 100644 index 000000000000..8a612b675bd2 --- /dev/null +++ b/samples/client/petstore/typescript/tests/jquery/weback.config.js @@ -0,0 +1,22 @@ +const path = require('path'); + +module.exports = { + entry: './tests.ts', + mode: "development", + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + } + ] + }, + resolve: { + extensions: [ '.tsx', '.ts', '.js' ] + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist') + } +}; \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/package-lock.json b/samples/client/petstore/typescript/tests/package-lock.json new file mode 100644 index 000000000000..48e341a0954d --- /dev/null +++ b/samples/client/petstore/typescript/tests/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} From 6c37c7180d138485499fe1402ae4a3663830aa29 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 5 May 2019 20:32:01 +0200 Subject: [PATCH 49/85] Added pom.xmls, fixed packagejsons and hopefully webppack --- .../typescript/builds/default/pom.xml | 33 +++++ .../petstore/typescript/builds/jquery/pom.xml | 59 +++++++++ .../typescript/tests/jquery/package-lock.json | 119 ------------------ .../typescript/tests/jquery/package.json | 6 +- .../petstore/typescript/tests/jquery/pom.xml | 13 ++ .../{weback.config.js => webpack.config.js} | 0 6 files changed, 106 insertions(+), 124 deletions(-) create mode 100644 samples/client/petstore/typescript/builds/jquery/pom.xml rename samples/client/petstore/typescript/tests/jquery/{weback.config.js => webpack.config.js} (100%) diff --git a/samples/client/petstore/typescript/builds/default/pom.xml b/samples/client/petstore/typescript/builds/default/pom.xml index e00676472b41..299b1f37912a 100644 --- a/samples/client/petstore/typescript/builds/default/pom.xml +++ b/samples/client/petstore/typescript/builds/default/pom.xml @@ -21,6 +21,39 @@ + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-build + pre-integration-test + + exec + + + npm + + run build + + + + + diff --git a/samples/client/petstore/typescript/builds/jquery/pom.xml b/samples/client/petstore/typescript/builds/jquery/pom.xml new file mode 100644 index 000000000000..53a2739492c5 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + org.openapitools + TypeScriptBuildPestoreClientSample + pom + 1.0-SNAPSHOT + TS Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-build + pre-integration-test + + exec + + + npm + + run build + + + + + + + + diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index a9e4f1f3dec3..eb7f676b0291 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -4,12 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/chai": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", - "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", - "dev": true - }, "@types/form-data": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", @@ -42,12 +36,6 @@ } } }, - "@types/mocha": { - "version": "2.2.48", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", - "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", - "dev": true - }, "@types/node": { "version": "8.10.48", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.48.tgz", @@ -324,12 +312,6 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -521,12 +503,6 @@ "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -567,20 +543,6 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, - "chai": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", - "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" - } - }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -596,12 +558,6 @@ "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -684,12 +640,6 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.15.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -778,15 +728,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -1321,12 +1262,6 @@ "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -1364,12 +1299,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -1452,12 +1381,6 @@ } } }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, "homedir-polyfill": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", @@ -1965,36 +1888,6 @@ } } }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "dependencies": { - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2172,12 +2065,6 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -3211,12 +3098,6 @@ "prelude-ls": "~1.1.2" } }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/client/petstore/typescript/tests/jquery/package.json index bddd4b85afbf..bca8f78c85d1 100644 --- a/samples/client/petstore/typescript/tests/jquery/package.json +++ b/samples/client/petstore/typescript/tests/jquery/package.json @@ -19,14 +19,10 @@ "scripts": { "prepublish": "npm install ../../builds/jquery && npm run build", "test": "node ./dist/test-runner.js", - "build": "tsc" + "build": "tsc && webpack" }, "devDependencies": { - "@types/chai": "^4.0.1", - "@types/mocha": "^2.2.41", "@types/node": "^8.10.48", - "chai": "^4.1.0", - "mocha": "^5.2.0", "ts-loader": "^4.3.1", "typescript": "^2.4.1" }, diff --git a/samples/client/petstore/typescript/tests/jquery/pom.xml b/samples/client/petstore/typescript/tests/jquery/pom.xml index d352f8131e11..4e6d211da437 100644 --- a/samples/client/petstore/typescript/tests/jquery/pom.xml +++ b/samples/client/petstore/typescript/tests/jquery/pom.xml @@ -39,6 +39,19 @@ + + npm-build + pre-integration-test + + exec + + + npm + + run build + + + npm-test integration-test diff --git a/samples/client/petstore/typescript/tests/jquery/weback.config.js b/samples/client/petstore/typescript/tests/jquery/webpack.config.js similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/weback.config.js rename to samples/client/petstore/typescript/tests/jquery/webpack.config.js From 9297e59053a8da82017dc7be9a4401fec3fac5db Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 5 May 2019 20:43:50 +0200 Subject: [PATCH 50/85] Removed tabs in TypeScriptClientCodegen --- .../languages/TypeScriptClientCodegen.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index aa4576730ef6..3252b2fc25f5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -57,7 +57,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo public TypeScriptClientCodegen() { super(); - + this.frameworkToHttpLibMap = new HashMap<>(); this.frameworkToHttpLibMap.put("fetch-api", "isomorphic-fetch"); this.frameworkToHttpLibMap.put("jquery", "jquery"); @@ -135,8 +135,8 @@ public TypeScriptClientCodegen() { CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { - // TODO: improve description? - frameworkOption.addEnum(option, option); + // TODO: improve description? + frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); System.out.println("Added framework option"); @@ -188,16 +188,16 @@ public CodegenType getTag() { } @Override - public Map postProcessSupportingFileData(Map objs) { - Map frameworks = new HashMap<>(); - for (String framework: FRAMEWORKS) { - frameworks.put(framework, framework.equals(additionalProperties.get(FRAMEWORK_SWITCH))); - } - objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH)); - objs.put("frameworks", frameworks); - - objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE)); - + public Map postProcessSupportingFileData(Map objs) { + Map frameworks = new HashMap<>(); + for (String framework: FRAMEWORKS) { + frameworks.put(framework, framework.equals(additionalProperties.get(FRAMEWORK_SWITCH))); + } + objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH)); + objs.put("frameworks", frameworks); + + objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE)); + return objs; } @@ -711,21 +711,21 @@ public void processOpts() { testPackage = this.testPackage + ".tests"; if (additionalProperties.containsKey(FRAMEWORK_SWITCH)) { - supportingFiles.add(new SupportingFile("generators/" + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", "index.ts")); + supportingFiles.add(new SupportingFile("generators/" + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", "index.ts")); } else { - additionalProperties.put(FRAMEWORK_SWITCH, FRAMEWORKS[0]); - supportingFiles.add(new SupportingFile("generators" + File.separator + FRAMEWORKS[0] + ".mustache", "index.ts")); + additionalProperties.put(FRAMEWORK_SWITCH, FRAMEWORKS[0]); + supportingFiles.add(new SupportingFile("generators" + File.separator + FRAMEWORKS[0] + ".mustache", "index.ts")); } String httpLibName = this.getHttpLibForFramework(additionalProperties.get(FRAMEWORK_SWITCH).toString()); supportingFiles.add(new SupportingFile("http" + File.separator + httpLibName + ".mustache", "http", httpLibName + ".ts")); } private String getHttpLibForFramework(String object) { - return this.frameworkToHttpLibMap.get(object); - } + return this.frameworkToHttpLibMap.get(object); + } - @Override + @Override public String getTypeDeclaration(Schema p) { Schema inner; if (ModelUtils.isArraySchema(p)) { From e4a0855db9a6491854977ce312eb1350c6c73385 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 5 May 2019 22:39:52 +0200 Subject: [PATCH 51/85] Fixed a couple issues with pom.xml --- .../typescript/http/isomorphic-fetch.mustache | 6 +- .../builds/default/http/isomorphic-fetch.ts | 9 +- .../typescript/builds/default/package.json | 2 +- .../typescript/builds/default/pom.xml | 3 +- .../typescript/builds/default/tsconfig.json | 2 +- .../typescript/builds/jquery/package.json | 2 +- .../petstore/typescript/builds/jquery/pom.xml | 5 +- .../typescript/tests/default/tsconfig.json | 3 +- .../typescript/tests/jquery/package-lock.json | 456 ++++++++++-------- .../typescript/tests/jquery/package.json | 1 - .../petstore/typescript/tests/jquery/pom.xml | 3 +- .../typescript/tests/jquery/tsconfig.json | 1 - 12 files changed, 278 insertions(+), 215 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index e6b5b183e679..f6552b10dc38 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,3 +1,5 @@ +declare var fetch: any; + import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' import { from, Observable } from 'rxjs'; @@ -15,7 +17,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { body: body as any, headers: request.getHeaders(), credentials: "same-origin" - }).then((resp) => { + }).then((resp: any) => { // hack let headers = (resp.headers as any)._headers; for (let key in headers) { @@ -27,7 +29,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { }); }); - return from(resultPromise); + return from>(resultPromise); } } diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index 2479f3d6ca74..f6552b10dc38 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -1,3 +1,5 @@ +declare var fetch: any; + import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' import { from, Observable } from 'rxjs'; @@ -15,20 +17,19 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary { body: body as any, headers: request.getHeaders(), credentials: "same-origin" - }).then((resp) => { + }).then((resp: any) => { // hack let headers = (resp.headers as any)._headers; for (let key in headers) { headers[key] = (headers[key] as Array).join("; "); } - console.log("Received headers: ", headers) + return resp.text().then((body: string) => { - console.log("Resp body ", body) return new ResponseContext(resp.status, headers, body) }); }); - return from(resultPromise); + return from>(resultPromise); } } diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index 01d8c238d6db..a5ec1718fec6 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -13,7 +13,7 @@ "license": "Unlicense", "main": "./dist/index.js", "typings": "./dist/index.d.ts", - "scripts" : { + "scripts": { "build": "tsc", "prepublishOnly": "npm run build" }, diff --git a/samples/client/petstore/typescript/builds/default/pom.xml b/samples/client/petstore/typescript/builds/default/pom.xml index 299b1f37912a..bf361b437145 100644 --- a/samples/client/petstore/typescript/builds/default/pom.xml +++ b/samples/client/petstore/typescript/builds/default/pom.xml @@ -48,7 +48,8 @@ npm - run build + run + build diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json index 142f3fa631a3..d60148962160 100644 --- a/samples/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -16,7 +16,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6", "dom" ] + "lib": [ "es6"] }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/jquery/package.json b/samples/client/petstore/typescript/builds/jquery/package.json index 34f8c7975f3c..3cf8a757e129 100644 --- a/samples/client/petstore/typescript/builds/jquery/package.json +++ b/samples/client/petstore/typescript/builds/jquery/package.json @@ -13,7 +13,7 @@ "license": "Unlicense", "main": "./dist/index.js", "typings": "./dist/index.d.ts", - "scripts" : { + "scripts": { "build": "tsc", "prepublishOnly": "npm run build" }, diff --git a/samples/client/petstore/typescript/builds/jquery/pom.xml b/samples/client/petstore/typescript/builds/jquery/pom.xml index 53a2739492c5..bf361b437145 100644 --- a/samples/client/petstore/typescript/builds/jquery/pom.xml +++ b/samples/client/petstore/typescript/builds/jquery/pom.xml @@ -21,7 +21,7 @@ - + org.codehaus.mojo exec-maven-plugin 1.2.1 @@ -48,7 +48,8 @@ npm - run build + run + build diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/client/petstore/typescript/tests/default/tsconfig.json index 4596f6e40bcf..04fbdfe41e26 100644 --- a/samples/client/petstore/typescript/tests/default/tsconfig.json +++ b/samples/client/petstore/typescript/tests/default/tsconfig.json @@ -10,8 +10,7 @@ "node" ], "lib": [ - "es6", - "dom" + "es6" ] }, "exclude": [ diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index eb7f676b0291..f212e11e31f0 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -13,9 +13,9 @@ }, "dependencies": { "@types/node": { - "version": "10.12.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", - "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" } } }, @@ -29,17 +29,18 @@ "parse5": "^4.0.0" }, "dependencies": { - "parse5": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", - "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==" + "@types/node": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" } } }, "@types/node": { "version": "8.10.48", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.48.tgz", - "integrity": "sha512-c35YEBTkL4rzXY2ucpSKy+UYHjUBIIkuJbWYbsGIrKLEWU5dgJMmLkkIb3qeC3O3Tpb1ZQCwecscvJTDjDjkRw==" + "integrity": "sha512-c35YEBTkL4rzXY2ucpSKy+UYHjUBIIkuJbWYbsGIrKLEWU5dgJMmLkkIb3qeC3O3Tpb1ZQCwecscvJTDjDjkRw==", + "dev": true }, "@types/qunit": { "version": "2.9.0", @@ -175,9 +176,9 @@ "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==" }, "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" }, "acorn-globals": { "version": "4.3.2", @@ -186,18 +187,11 @@ "requires": { "acorn": "^6.0.1", "acorn-walk": "^6.0.1" - }, - "dependencies": { - "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" - } } }, "acorn-jsx": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "requires": { "acorn": "^3.0.4" @@ -205,7 +199,7 @@ "dependencies": { "acorn": { "version": "3.3.0", - "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" } } @@ -224,14 +218,14 @@ } }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", + "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, "ajv-keywords": { @@ -240,9 +234,9 @@ "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" }, "ansi-escapes": { - "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", - "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==" }, "ansi-regex": { "version": "2.1.1", @@ -250,12 +244,9 @@ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, "argparse": { "version": "1.0.10", @@ -354,14 +345,9 @@ "js-tokens": "^3.0.2" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" - }, "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "requires": { "ansi-styles": "^2.2.1", @@ -373,16 +359,11 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" } } }, @@ -535,7 +516,7 @@ }, "callsites": { "version": "0.2.0", - "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" }, "caseless": { @@ -544,13 +525,31 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } } }, "chardet": { @@ -640,6 +639,11 @@ "delayed-stream": "~1.0.0" } }, + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==" + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -715,11 +719,11 @@ } }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "decode-uri-component": { @@ -863,24 +867,11 @@ "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.6.1" - }, - "dependencies": { - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true - } } }, "eslint": { "version": "4.19.1", - "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", "requires": { "ajv": "^5.3.0", @@ -921,6 +912,37 @@ "strip-json-comments": "~2.0.1", "table": "4.0.2", "text-table": "~0.2.0" + }, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + } } }, "eslint-scope": { @@ -939,17 +961,24 @@ }, "espree": { "version": "3.5.4", - "resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "requires": { "acorn": "^5.5.0", "acorn-jsx": "^3.0.0" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + } } }, "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" }, "esquery": { "version": "1.0.1", @@ -1018,6 +1047,12 @@ "requires": { "is-extendable": "^0.1.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -1049,7 +1084,7 @@ }, "external-editor": { "version": "2.2.0", - "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", "requires": { "chardet": "^0.4.0", @@ -1140,6 +1175,11 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" } } }, @@ -1149,9 +1189,9 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, "fast-deep-equal": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-stable-stringify": { "version": "2.0.0", @@ -1277,9 +1317,9 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1290,14 +1330,14 @@ } }, "globals": { - "version": "11.9.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", - "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==" + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, "har-schema": { "version": "2.0.0", @@ -1311,29 +1351,6 @@ "requires": { "ajv": "^6.5.5", "har-schema": "^2.0.0" - }, - "dependencies": { - "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - } } }, "has-ansi": { @@ -1382,9 +1399,9 @@ } }, "homedir-polyfill": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", "requires": { "parse-passwd": "^1.0.0" } @@ -1414,6 +1431,16 @@ "requires": { "agent-base": "^4.1.0", "debug": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } } }, "iconv-lite": { @@ -1633,6 +1660,13 @@ "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + } } }, "jsbn": { @@ -1673,10 +1707,10 @@ "xml-name-validator": "^3.0.0" }, "dependencies": { - "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" } } }, @@ -1686,9 +1720,9 @@ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -1707,6 +1741,14 @@ "dev": true, "requires": { "minimist": "^1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } } }, "jsprim": { @@ -1822,16 +1864,16 @@ "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" }, "mime-db": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", - "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", - "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.36.0" + "mime-db": "1.40.0" } }, "mimic-fn": { @@ -1848,9 +1890,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "mixin-deep": { "version": "1.3.1", @@ -1875,23 +1917,16 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - } } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "mute-stream": { "version": "0.0.7", @@ -2031,7 +2066,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "parse-passwd": { @@ -2040,9 +2075,9 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" }, "parse5": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", - "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", + "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==" }, "pascalcase": { "version": "0.1.1", @@ -2102,9 +2137,9 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, "progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", - "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, "proxy-from-env": { "version": "1.0.0", @@ -2145,21 +2180,6 @@ "proxy-from-env": "^1.0.0", "rimraf": "^2.6.1", "ws": "^6.1.0" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - } } }, "qs": { @@ -2177,18 +2197,11 @@ "minimatch": "3.0.4", "node-watch": "0.6.0", "resolve": "1.9.0" - }, - "dependencies": { - "commander": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", - "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==" - } } }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -2212,7 +2225,7 @@ }, "regexpp": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" }, "repeat-element": { @@ -2290,7 +2303,7 @@ }, "require-uncached": { "version": "1.0.3", - "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "requires": { "caller-path": "^0.1.0", @@ -2345,11 +2358,11 @@ } }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "run-async": { @@ -2374,9 +2387,9 @@ } }, "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", "requires": { "tslib": "^1.9.0" } @@ -2409,9 +2422,9 @@ } }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, "set-value": { "version": "2.0.0", @@ -2504,6 +2517,18 @@ "requires": { "is-extendable": "^0.1.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true } } }, @@ -2579,9 +2604,10 @@ } }, "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true }, "source-map-resolve": { "version": "0.5.2", @@ -2602,6 +2628,13 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "requires": { "source-map": "^0.5.6" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + } } }, "source-map-url": { @@ -2709,12 +2742,9 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" }, "symbol-tree": { "version": "3.2.2", @@ -2732,6 +2762,29 @@ "lodash": "^4.17.4", "slice-ansi": "1.0.0", "string-width": "^2.1.1" + }, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + } } }, "tapable": { @@ -2747,7 +2800,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "tmp": { @@ -2818,9 +2871,9 @@ } }, "ts-loader": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-4.3.1.tgz", - "integrity": "sha512-ra304bebnyxd9nIJoKjQoeQLOENqrDG7vfppS+DkCnqOEv29GuiiWMvgebuCqFko0AkMFpoubRLeFM7YmlkL3w==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-4.5.0.tgz", + "integrity": "sha512-ihgVaSmgrX4crGV4n7yuoHPoCHbDzj9aepCZR9TgIx4SgJ9gdnB6xLHgUBb7bsFM/f0K6x9iXa65KY/Fu1Klkw==", "dev": true, "requires": { "chalk": "^2.3.0", @@ -2845,6 +2898,13 @@ "tsconfig": "^6.0.0", "v8flags": "^3.0.0", "yn": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } } }, "ts-petstore-client": { @@ -3215,9 +3275,9 @@ "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "v8flags": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", - "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", + "integrity": "sha512-MtivA7GF24yMPte9Rp/BWGCYQNaUj86zeYxV/x2RRJMKagImbbv3u8iJC57lNhWLPcGLJmHcHmFWkNsplbbLWw==", "requires": { "homedir-polyfill": "^1.0.1" } diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/client/petstore/typescript/tests/jquery/package.json index bca8f78c85d1..c2f0c14eb111 100644 --- a/samples/client/petstore/typescript/tests/jquery/package.json +++ b/samples/client/petstore/typescript/tests/jquery/package.json @@ -17,7 +17,6 @@ "ts-petstore-client": "file:../../builds/jquery" }, "scripts": { - "prepublish": "npm install ../../builds/jquery && npm run build", "test": "node ./dist/test-runner.js", "build": "tsc && webpack" }, diff --git a/samples/client/petstore/typescript/tests/jquery/pom.xml b/samples/client/petstore/typescript/tests/jquery/pom.xml index 4e6d211da437..ed382e65631d 100644 --- a/samples/client/petstore/typescript/tests/jquery/pom.xml +++ b/samples/client/petstore/typescript/tests/jquery/pom.xml @@ -48,7 +48,8 @@ npm - run build + run + build diff --git a/samples/client/petstore/typescript/tests/jquery/tsconfig.json b/samples/client/petstore/typescript/tests/jquery/tsconfig.json index 4596f6e40bcf..a3d61c5ac815 100644 --- a/samples/client/petstore/typescript/tests/jquery/tsconfig.json +++ b/samples/client/petstore/typescript/tests/jquery/tsconfig.json @@ -6,7 +6,6 @@ "sourceMap": false, "outDir": "dist", "types": [ - "mocha", "node" ], "lib": [ From 5fd3be29bdd7e87c18b06165636c74f4ee4007f1 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 5 May 2019 22:58:45 +0200 Subject: [PATCH 52/85] Ensured up to date --- bin/typescript.sh | 5 +++ .../languages/TypeScriptClientCodegen.java | 5 +-- .../resources/typescript/package.mustache | 2 +- .../typescript-jquery/default/api/StoreApi.ts | 1 + .../typescript/builds/default/http/http.ts | 1 - .../typescript/builds/default/package.json | 2 +- .../typescript/builds/default/tsconfig.json | 2 +- .../builds/jquery/http/isomorphic-fetch.ts | 33 +++++++++++++++++++ 8 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts diff --git a/bin/typescript.sh b/bin/typescript.sh index 78e2ab585eb3..8a0de14cc0a8 100755 --- a/bin/typescript.sh +++ b/bin/typescript.sh @@ -27,6 +27,11 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +echo "Creating default (fetch) client!" ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default $@" java $JAVA_OPTS -jar $executable $ags +echo "Creating jquery client!" +ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,fileContentDataType=Blob $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 3252b2fc25f5..6dfe6310a246 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -139,7 +139,7 @@ public TypeScriptClientCodegen() { frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); - System.out.println("Added framework option"); + cliOptions.add(frameworkOption); @@ -196,7 +196,8 @@ public Map postProcessSupportingFileData(Map obj objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH)); objs.put("frameworks", frameworks); - objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE)); + Object propDataType = additionalProperties.get(FILE_CONTENT_DATA_TYPE); + objs.put("fileContentDataType", propDataType == null ? "Buffer" : propDataType); return objs; } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index dbd976a82756..42663fc5c298 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -13,7 +13,7 @@ "license": "Unlicense", "main": "./dist/index.js", "typings": "./dist/index.d.ts", - "scripts" : { + "scripts": { "build": "tsc", "prepublishOnly": "npm run build" }, diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts index 1ab37edc539c..cf2b58ec9d9e 100644 --- a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -18,6 +18,7 @@ import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ + export class StoreApi { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders: Array = []; diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 0da0d8125404..a5dd14037092 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -5,7 +5,6 @@ import * as FormData from "form-data"; import * as URLParse from "url-parse"; import { Observable } from 'rxjs'; - export * from './isomorphic-fetch'; /** diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index a5ec1718fec6..5cd927c2810f 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -20,8 +20,8 @@ "dependencies": { "es6-promise": "^4.2.4", "isomorphic-fetch": "^2.2.1", - "btoa": "^1.2.1", "@types/isomorphic-fetch": "0.0.34", + "btoa": "^1.2.1", "form-data": "^2.3.2", "@types/form-data": "^2.2.1", "url-parse": "^1.4.3", diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json index d60148962160..142f3fa631a3 100644 --- a/samples/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -16,7 +16,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6"] + "lib": [ "es6", "dom" ] }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..e6b5b183e679 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts @@ -0,0 +1,33 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import * as e6p from 'es6-promise' +import { from, Observable } from 'rxjs'; +e6p.polyfill(); +import 'isomorphic-fetch'; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + const resultPromise = fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + credentials: "same-origin" + }).then((resp) => { + // hack + let headers = (resp.headers as any)._headers; + for (let key in headers) { + headers[key] = (headers[key] as Array).join("; "); + } + + return resp.text().then((body: string) => { + return new ResponseContext(resp.status, headers, body) + }); + }); + + return from(resultPromise); + + } +} From 68241f8c33f259b7be63c62378bfc86bfc2ed32a Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 6 May 2019 12:03:07 +0200 Subject: [PATCH 53/85] Fixed missing fetch definition in TS default tests --- .../petstore/typescript/tests/default/package-lock.json | 6 +++--- .../client/petstore/typescript/tests/default/tsconfig.json | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 609eb4d29091..6ca04437ef22 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -831,9 +831,9 @@ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/client/petstore/typescript/tests/default/tsconfig.json index 04fbdfe41e26..4596f6e40bcf 100644 --- a/samples/client/petstore/typescript/tests/default/tsconfig.json +++ b/samples/client/petstore/typescript/tests/default/tsconfig.json @@ -10,7 +10,8 @@ "node" ], "lib": [ - "es6" + "es6", + "dom" ] }, "exclude": [ From 4f461f948a115a6d159a8bfa63e6938ba8e80f59 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 6 May 2019 12:07:03 +0200 Subject: [PATCH 54/85] Updated typescript docs --- docs/generators/typescript.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 2cf632734794..20948b6b54c0 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -13,3 +13,5 @@ sidebar_label: typescript |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| +|fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| +|framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| From 0f3ad99d728bbbf03b0a02918574568cbe26c091 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 1 Nov 2019 16:04:18 +0100 Subject: [PATCH 55/85] Refactor typescript merge master (#4319) Merge master into ts-refactor --- .gitignore | 1 - docs/generators/typescript.md | 2 -- 2 files changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index d8355b3df3bf..2b1fa3629b05 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ out/ classpath.txt version.properties modules/openapi-generator-gradle-plugin/bin/ -modules/openapi-generator-cli/bin/ !modules/openapi-generator-cli/src/main/resources/version.properties .project .classpath diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 20948b6b54c0..e5d3540d8acb 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -1,6 +1,4 @@ - --- -id: generator-opts-client-typescript title: Config Options for typescript sidebar_label: typescript --- From 0000342d770d5b57a47d09f915397cb3d9341659 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Tue, 19 Nov 2019 17:48:08 +0100 Subject: [PATCH 56/85] Typescript refactor: stub rxjs (#4424) * Remove unused supportsES6 field from codegen * Add a new switch for RXJS * Remove redundant npm dependency on rxjs4 types * Fix return type of PromiseMiddleware methods * Install webpack dependency to run jquery tests * Update form-data to 2.5 which includes typings * Add missing dependency on node typings * Fix test artifact name typo * Stub rxjs when it is not explicitly enabled --- docs/generators/typescript.md | 1 + .../languages/TypeScriptClientCodegen.java | 33 +- .../typescript/api/middleware.mustache | 6 +- .../generators/types/ObservableAPI.mustache | 4 +- .../resources/typescript/http/http.mustache | 2 +- .../typescript/http/isomorphic-fetch.mustache | 2 +- .../resources/typescript/http/jquery.mustache | 2 +- .../resources/typescript/package.mustache | 11 +- .../resources/typescript/rxjsStub.mustache | 27 + .../typescript/builds/default/http/http.ts | 2 +- .../builds/default/http/isomorphic-fetch.ts | 2 +- .../typescript/builds/default/middleware.ts | 6 +- .../builds/default/package-lock.json | 166 +- .../typescript/builds/default/package.json | 8 +- .../typescript/builds/default/pom.xml | 2 +- .../typescript/builds/default/rxjsStub.ts | 27 + .../builds/default/types/ObservableAPI.ts | 4 +- .../typescript/builds/jquery/http/http.ts | 2 +- .../builds/jquery/http/isomorphic-fetch.ts | 33 - .../typescript/builds/jquery/http/jquery.ts | 2 +- .../typescript/builds/jquery/middleware.ts | 6 +- .../builds/jquery/package-lock.json | 152 +- .../typescript/builds/jquery/package.json | 8 +- .../petstore/typescript/builds/jquery/pom.xml | 2 +- .../typescript/builds/jquery/rxjsStub.ts | 27 + .../builds/jquery/types/ObservableAPI.ts | 4 +- .../tests/default/package-lock.json | 303 +- .../typescript/tests/default/package.json | 5 +- .../petstore/typescript/tests/default/pom.xml | 2 +- .../test/http/isomorphic-fetch.test.ts | 8 +- .../typescript/tests/jquery/package-lock.json | 2618 +++++++++++++++-- .../typescript/tests/jquery/package.json | 9 +- .../petstore/typescript/tests/jquery/pom.xml | 2 +- .../tests/jquery/test/http/jquery.test.ts | 6 +- 34 files changed, 2534 insertions(+), 960 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/rxjsStub.mustache create mode 100644 samples/client/petstore/typescript/builds/default/rxjsStub.ts delete mode 100644 samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts create mode 100644 samples/client/petstore/typescript/builds/jquery/rxjsStub.ts diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index e5d3540d8acb..11ebf4ce2910 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -12,4 +12,5 @@ sidebar_label: typescript |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| +|useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 6dfe6310a246..b65346fbcbd9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -48,11 +48,12 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String[] FRAMEWORKS = { "fetch-api", "jquery" }; private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)"; - + private static final String USE_RXJS_SWITCH = "useRxJS"; + private static final String USE_RXJS_SWITCH_DESC = "Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework."; + private final Map frameworkToHttpLibMap; protected String modelPropertyNaming = "camelCase"; - protected boolean supportsES6 = true; protected HashSet languageGenericTypes; public TypeScriptClientCodegen() { @@ -132,6 +133,7 @@ public TypeScriptClientCodegen() { 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")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false")); CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { @@ -644,14 +646,6 @@ public Map postProcessAllModels(Map objs) { return result; } - public void setSupportsES6(Boolean value) { - supportsES6 = value; - } - - public Boolean getSupportsES6() { - return supportsES6; - } - private void setDiscriminatorValue(CodegenModel model, String baseName, String value) { for (CodegenProperty prop : model.allVars) { if (prop.baseName.equals(baseName)) { @@ -702,10 +696,12 @@ public void processOpts() { } if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) { - setSupportsES6(Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString())); - additionalProperties.put("supportsES6", getSupportsES6()); + // convert to boolean + additionalProperties.put(CodegenConstants.SUPPORTS_ES6, + Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString()) + ); } - + // change package names apiPackage = this.apiPackage + ".apis"; modelPackage = this.modelPackage + ".models"; @@ -719,6 +715,17 @@ public void processOpts() { } String httpLibName = this.getHttpLibForFramework(additionalProperties.get(FRAMEWORK_SWITCH).toString()); supportingFiles.add(new SupportingFile("http" + File.separator + httpLibName + ".mustache", "http", httpLibName + ".ts")); + + boolean useRxJS = false; + if (additionalProperties.containsKey(USE_RXJS_SWITCH)) { + // convert to boolean + useRxJS = Boolean.valueOf(additionalProperties.get(USE_RXJS_SWITCH).toString()); + additionalProperties.put(USE_RXJS_SWITCH, useRxJS); + } + if (!useRxJS) { + supportingFiles.add(new SupportingFile("rxjsStub.mustache", "", "rxjsStub.ts")); + } + } private String getHttpLibForFramework(String object) { diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index f3b038ea17cb..1c5929a2d005 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -1,5 +1,5 @@ import {RequestContext, ResponseContext} from './http/http'; -import { Observable, from } from 'rxjs'; +import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'./rxjsStub'{{/useRxJS}}; /** * Defines the contract for a middleware intercepting requests before @@ -55,12 +55,12 @@ export interface PromiseMiddleware { * @returns an observable of the updated request context * */ - pre(context: RequestContext): Observable; + pre(context: RequestContext): Promise; /** * Modifies the returned response before it is deserialized. * * @param context ResponseContext of a sent request * @returns an observable of the modified response context */ - post(context: ResponseContext): Observable; + post(context: ResponseContext): Promise; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache index 75a48dea6456..95052bde59bd 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache @@ -1,8 +1,8 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from 'rxjs'; -import {mergeMap, map} from 'rxjs/operators'; +import { Observable, of } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; +import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; {{#models}} {{#model}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 8678e655c1d1..a4b6edc4445a 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -3,7 +3,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from 'rxjs'; +import { Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; {{#frameworks}} {{#fetch-api}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index f6552b10dc38..ef6b2960f6f6 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -2,7 +2,7 @@ declare var fetch: any; import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' -import { from, Observable } from 'rxjs'; +import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; e6p.polyfill(); import 'isomorphic-fetch'; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index fa82596128da..4d641b17bb79 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -1,6 +1,6 @@ import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; import * as e6p from 'es6-promise' -import { from, Observable } from 'rxjs'; +import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; e6p.polyfill(); import * as $ from 'jquery'; import * as FormData from "form-data"; diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 42663fc5c298..16087369be4d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -19,6 +19,7 @@ }, "dependencies": { "es6-promise": "^4.2.4", + "@types/node": "*", {{#frameworks}} {{#fetch-api}} "isomorphic-fetch": "^2.2.1", @@ -30,11 +31,11 @@ {{/jquery}} {{/frameworks}} "btoa": "^1.2.1", - "form-data": "^2.3.2", - "@types/form-data": "^2.2.1", - "url-parse": "^1.4.3", - "rxjs": "^6.4.0", - "@types/rx": "^4.1.1" + "form-data": "^2.5.0", + {{#useRxJS}} + "rxjs": "^6.4.0", + {{/useRxJS}} + "url-parse": "^1.4.3" }, "devDependencies": { "typescript": "^2.9.2" diff --git a/modules/openapi-generator/src/main/resources/typescript/rxjsStub.mustache b/modules/openapi-generator/src/main/resources/typescript/rxjsStub.mustache new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/rxjsStub.mustache @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index a5dd14037092..415a86c7d19e 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -3,7 +3,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from 'rxjs'; +import { Observable } from '../rxjsStub'; export * from './isomorphic-fetch'; diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index f6552b10dc38..0793c34bf44f 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -2,7 +2,7 @@ declare var fetch: any; import {HttpLibrary, RequestContext, ResponseContext} from './http'; import * as e6p from 'es6-promise' -import { from, Observable } from 'rxjs'; +import { from, Observable } from '../rxjsStub'; e6p.polyfill(); import 'isomorphic-fetch'; diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/client/petstore/typescript/builds/default/middleware.ts index f3b038ea17cb..46da5d25ef07 100644 --- a/samples/client/petstore/typescript/builds/default/middleware.ts +++ b/samples/client/petstore/typescript/builds/default/middleware.ts @@ -1,5 +1,5 @@ import {RequestContext, ResponseContext} from './http/http'; -import { Observable, from } from 'rxjs'; +import { Observable, from } from './rxjsStub'; /** * Defines the contract for a middleware intercepting requests before @@ -55,12 +55,12 @@ export interface PromiseMiddleware { * @returns an observable of the updated request context * */ - pre(context: RequestContext): Observable; + pre(context: RequestContext): Promise; /** * Modifies the returned response before it is deserialized. * * @param context ResponseContext of a sent request * @returns an observable of the modified response context */ - post(context: ResponseContext): Observable; + post(context: ResponseContext): Promise; } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index 3420dfb5cb3c..e91cff7ebba9 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -4,136 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - } - }, "@types/isomorphic-fetch": { "version": "0.0.34", "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" }, "@types/node": { - "version": "10.12.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", - "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" - }, - "@types/rx": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", - "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*", - "@types/rx-lite": "*", - "@types/rx-lite-aggregates": "*", - "@types/rx-lite-async": "*", - "@types/rx-lite-backpressure": "*", - "@types/rx-lite-coincidence": "*", - "@types/rx-lite-experimental": "*", - "@types/rx-lite-joinpatterns": "*", - "@types/rx-lite-testing": "*", - "@types/rx-lite-time": "*", - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-core": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", - "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" - }, - "@types/rx-core-binding": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", - "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", - "requires": { - "@types/rx-core": "*" - } - }, - "@types/rx-lite": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", - "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*" - } - }, - "@types/rx-lite-aggregates": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", - "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-async": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", - "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-backpressure": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", - "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-coincidence": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", - "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-experimental": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", - "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-joinpatterns": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", - "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-testing": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", - "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", - "requires": { - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-lite-time": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", - "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-virtualtime": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", - "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", - "requires": { - "@types/rx-lite": "*" - } + "version": "12.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, "asynckit": { "version": "0.4.0", @@ -146,9 +25,9 @@ "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } @@ -172,9 +51,9 @@ "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" }, "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -204,16 +83,16 @@ } }, "mime-db": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", - "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", - "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.36.0" + "mime-db": "1.40.0" } }, "node-fetch": { @@ -235,24 +114,11 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", - "requires": { - "tslib": "^1.9.0" - } - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" - }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index 5cd927c2810f..d1a961e18a0c 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -19,14 +19,12 @@ }, "dependencies": { "es6-promise": "^4.2.4", + "@types/node": "*", "isomorphic-fetch": "^2.2.1", "@types/isomorphic-fetch": "0.0.34", "btoa": "^1.2.1", - "form-data": "^2.3.2", - "@types/form-data": "^2.2.1", - "url-parse": "^1.4.3", - "rxjs": "^6.4.0", - "@types/rx": "^4.1.1" + "form-data": "^2.5.0", + "url-parse": "^1.4.3" }, "devDependencies": { "typescript": "^2.9.2" diff --git a/samples/client/petstore/typescript/builds/default/pom.xml b/samples/client/petstore/typescript/builds/default/pom.xml index bf361b437145..ad8b1d386fcc 100644 --- a/samples/client/petstore/typescript/builds/default/pom.xml +++ b/samples/client/petstore/typescript/builds/default/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptBuildPestoreClientSample + TypeScriptBuildPetstoreClientSample pom 1.0-SNAPSHOT TS Default Petstore Client diff --git a/samples/client/petstore/typescript/builds/default/rxjsStub.ts b/samples/client/petstore/typescript/builds/default/rxjsStub.ts new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 079853bb913a..1c31558e9b21 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -1,8 +1,8 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from 'rxjs'; -import {mergeMap, map} from 'rxjs/operators'; +import { Observable, of } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 140f65c72e6a..0e5f142952dc 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -3,7 +3,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from 'rxjs'; +import { Observable } from '../rxjsStub'; export * from './jquery'; diff --git a/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts deleted file mode 100644 index e6b5b183e679..000000000000 --- a/samples/client/petstore/typescript/builds/jquery/http/isomorphic-fetch.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import * as e6p from 'es6-promise' -import { from, Observable } from 'rxjs'; -e6p.polyfill(); -import 'isomorphic-fetch'; - -export class IsomorphicFetchHttpLibrary implements HttpLibrary { - - public send(request: RequestContext): Observable { - let method = request.getHttpMethod().toString(); - let body = request.getBody(); - - const resultPromise = fetch(request.getUrl(), { - method: method, - body: body as any, - headers: request.getHeaders(), - credentials: "same-origin" - }).then((resp) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body: string) => { - return new ResponseContext(resp.status, headers, body) - }); - }); - - return from(resultPromise); - - } -} diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts index fa82596128da..3803cc7dbd55 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -1,6 +1,6 @@ import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; import * as e6p from 'es6-promise' -import { from, Observable } from 'rxjs'; +import { from, Observable } from '../rxjsStub'; e6p.polyfill(); import * as $ from 'jquery'; import * as FormData from "form-data"; diff --git a/samples/client/petstore/typescript/builds/jquery/middleware.ts b/samples/client/petstore/typescript/builds/jquery/middleware.ts index f3b038ea17cb..46da5d25ef07 100644 --- a/samples/client/petstore/typescript/builds/jquery/middleware.ts +++ b/samples/client/petstore/typescript/builds/jquery/middleware.ts @@ -1,5 +1,5 @@ import {RequestContext, ResponseContext} from './http/http'; -import { Observable, from } from 'rxjs'; +import { Observable, from } from './rxjsStub'; /** * Defines the contract for a middleware intercepting requests before @@ -55,12 +55,12 @@ export interface PromiseMiddleware { * @returns an observable of the updated request context * */ - pre(context: RequestContext): Observable; + pre(context: RequestContext): Promise; /** * Modifies the returned response before it is deserialized. * * @param context ResponseContext of a sent request * @returns an observable of the modified response context */ - post(context: ResponseContext): Observable; + post(context: ResponseContext): Promise; } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/client/petstore/typescript/builds/jquery/package-lock.json index 81d989625da1..d64ff033dae8 100644 --- a/samples/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/client/petstore/typescript/builds/jquery/package-lock.json @@ -4,14 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - } - }, "@types/jquery": { "version": "3.3.29", "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", @@ -21,122 +13,9 @@ } }, "@types/node": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", - "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" - }, - "@types/rx": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", - "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*", - "@types/rx-lite": "*", - "@types/rx-lite-aggregates": "*", - "@types/rx-lite-async": "*", - "@types/rx-lite-backpressure": "*", - "@types/rx-lite-coincidence": "*", - "@types/rx-lite-experimental": "*", - "@types/rx-lite-joinpatterns": "*", - "@types/rx-lite-testing": "*", - "@types/rx-lite-time": "*", - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-core": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", - "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" - }, - "@types/rx-core-binding": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", - "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", - "requires": { - "@types/rx-core": "*" - } - }, - "@types/rx-lite": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", - "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*" - } - }, - "@types/rx-lite-aggregates": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", - "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-async": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", - "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-backpressure": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", - "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-coincidence": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", - "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-experimental": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", - "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-joinpatterns": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", - "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-testing": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", - "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", - "requires": { - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-lite-time": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", - "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-virtualtime": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", - "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", - "requires": { - "@types/rx-lite": "*" - } + "version": "12.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, "@types/sizzle": { "version": "2.3.2", @@ -154,9 +33,9 @@ "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } @@ -172,9 +51,9 @@ "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -209,19 +88,6 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "rxjs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", - "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", - "requires": { - "tslib": "^1.9.0" - } - }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" - }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", diff --git a/samples/client/petstore/typescript/builds/jquery/package.json b/samples/client/petstore/typescript/builds/jquery/package.json index 3cf8a757e129..fdcb5251e3c4 100644 --- a/samples/client/petstore/typescript/builds/jquery/package.json +++ b/samples/client/petstore/typescript/builds/jquery/package.json @@ -19,14 +19,12 @@ }, "dependencies": { "es6-promise": "^4.2.4", + "@types/node": "*", "@types/jquery": "^3.3.29", "jquery": "^3.4.1", "btoa": "^1.2.1", - "form-data": "^2.3.2", - "@types/form-data": "^2.2.1", - "url-parse": "^1.4.3", - "rxjs": "^6.4.0", - "@types/rx": "^4.1.1" + "form-data": "^2.5.0", + "url-parse": "^1.4.3" }, "devDependencies": { "typescript": "^2.9.2" diff --git a/samples/client/petstore/typescript/builds/jquery/pom.xml b/samples/client/petstore/typescript/builds/jquery/pom.xml index bf361b437145..ad8b1d386fcc 100644 --- a/samples/client/petstore/typescript/builds/jquery/pom.xml +++ b/samples/client/petstore/typescript/builds/jquery/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptBuildPestoreClientSample + TypeScriptBuildPetstoreClientSample pom 1.0-SNAPSHOT TS Default Petstore Client diff --git a/samples/client/petstore/typescript/builds/jquery/rxjsStub.ts b/samples/client/petstore/typescript/builds/jquery/rxjsStub.ts new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/samples/client/petstore/typescript/builds/jquery/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts b/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts index 079853bb913a..1c31558e9b21 100644 --- a/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts +++ b/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts @@ -1,8 +1,8 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from 'rxjs'; -import {mergeMap, map} from 'rxjs/operators'; +import { Observable, of } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 6ca04437ef22..d4543da26987 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -10,21 +10,6 @@ "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", "dev": true }, - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "10.12.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", - "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" - } - } - }, "@types/isomorphic-fetch": { "version": "0.0.34", "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", @@ -48,119 +33,6 @@ "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" }, - "@types/rx": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", - "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*", - "@types/rx-lite": "*", - "@types/rx-lite-aggregates": "*", - "@types/rx-lite-async": "*", - "@types/rx-lite-backpressure": "*", - "@types/rx-lite-coincidence": "*", - "@types/rx-lite-experimental": "*", - "@types/rx-lite-joinpatterns": "*", - "@types/rx-lite-testing": "*", - "@types/rx-lite-time": "*", - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-core": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", - "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" - }, - "@types/rx-core-binding": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", - "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", - "requires": { - "@types/rx-core": "*" - } - }, - "@types/rx-lite": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", - "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*" - } - }, - "@types/rx-lite-aggregates": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", - "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-async": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", - "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-backpressure": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", - "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-coincidence": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", - "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-experimental": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", - "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-joinpatterns": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", - "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-testing": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", - "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", - "requires": { - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-lite-time": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", - "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-virtualtime": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", - "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", - "requires": { - "@types/rx-lite": "*" - } - }, "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", @@ -397,9 +269,9 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } @@ -666,9 +538,9 @@ } }, "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -905,16 +777,16 @@ } }, "mime-db": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", - "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", - "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.36.0" + "mime-db": "1.40.0" } }, "mimic-fn": { @@ -1165,14 +1037,6 @@ "rx-lite": "*" } }, - "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -1351,132 +1215,23 @@ "ts-petstore-client": { "version": "file:../../builds/default", "requires": { - "@types/form-data": "^2.2.1", "@types/isomorphic-fetch": "0.0.34", - "@types/rx": "^4.1.1", + "@types/node": "*", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "form-data": "^2.3.2", + "form-data": "^2.5.0", "isomorphic-fetch": "^2.2.1", - "rxjs": "^6.4.0", "url-parse": "^1.4.3" }, "dependencies": { - "@types/form-data": { - "version": "2.2.1", - "bundled": true, - "requires": { - "@types/node": "*" - } - }, "@types/isomorphic-fetch": { "version": "0.0.34", "bundled": true }, "@types/node": { - "version": "10.12.0", + "version": "12.12.7", "bundled": true }, - "@types/rx": { - "version": "4.1.1", - "bundled": true, - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*", - "@types/rx-lite": "*", - "@types/rx-lite-aggregates": "*", - "@types/rx-lite-async": "*", - "@types/rx-lite-backpressure": "*", - "@types/rx-lite-coincidence": "*", - "@types/rx-lite-experimental": "*", - "@types/rx-lite-joinpatterns": "*", - "@types/rx-lite-testing": "*", - "@types/rx-lite-time": "*", - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-core": { - "version": "4.0.3", - "bundled": true - }, - "@types/rx-core-binding": { - "version": "4.0.4", - "bundled": true, - "requires": { - "@types/rx-core": "*" - } - }, - "@types/rx-lite": { - "version": "4.0.6", - "bundled": true, - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*" - } - }, - "@types/rx-lite-aggregates": { - "version": "4.0.3", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-async": { - "version": "4.0.2", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-backpressure": { - "version": "4.0.3", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-coincidence": { - "version": "4.0.3", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-experimental": { - "version": "4.0.1", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-joinpatterns": { - "version": "4.0.1", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-testing": { - "version": "4.0.1", - "bundled": true, - "requires": { - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-lite-time": { - "version": "4.0.3", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, - "@types/rx-lite-virtualtime": { - "version": "4.0.3", - "bundled": true, - "requires": { - "@types/rx-lite": "*" - } - }, "asynckit": { "version": "0.4.0", "bundled": true @@ -1486,7 +1241,7 @@ "bundled": true }, "combined-stream": { - "version": "1.0.7", + "version": "1.0.8", "bundled": true, "requires": { "delayed-stream": "~1.0.0" @@ -1508,7 +1263,7 @@ "bundled": true }, "form-data": { - "version": "2.3.3", + "version": "2.5.1", "bundled": true, "requires": { "asynckit": "^0.4.0", @@ -1536,14 +1291,14 @@ } }, "mime-db": { - "version": "1.36.0", + "version": "1.40.0", "bundled": true }, "mime-types": { - "version": "2.1.20", + "version": "2.1.24", "bundled": true, "requires": { - "mime-db": "~1.36.0" + "mime-db": "1.40.0" } }, "node-fetch": { @@ -1562,21 +1317,10 @@ "version": "1.0.0", "bundled": true }, - "rxjs": { - "version": "6.4.0", - "bundled": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safer-buffer": { "version": "2.1.2", "bundled": true }, - "tslib": { - "version": "1.9.3", - "bundled": true - }, "typescript": { "version": "2.9.2", "bundled": true @@ -1604,11 +1348,6 @@ "strip-json-comments": "^2.0.0" } }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" - }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", diff --git a/samples/client/petstore/typescript/tests/default/package.json b/samples/client/petstore/typescript/tests/default/package.json index d88b1e07f9fc..2de26fc0d717 100644 --- a/samples/client/petstore/typescript/tests/default/package.json +++ b/samples/client/petstore/typescript/tests/default/package.json @@ -1,12 +1,9 @@ { "private": true, "dependencies": { - "@types/form-data": "^2.2.1", "@types/rewire": "^2.5.28", - "@types/rx": "^4.1.1", - "form-data": "^2.3.2", + "form-data": "^2.5.0", "rewire": "^4.0.1", - "rxjs": "^6.4.0", "ts-node": "^3.3.0", "ts-petstore-client": "file:../../builds/default" }, diff --git a/samples/client/petstore/typescript/tests/default/pom.xml b/samples/client/petstore/typescript/tests/default/pom.xml index d352f8131e11..6cf652cef1e9 100644 --- a/samples/client/petstore/typescript/tests/default/pom.xml +++ b/samples/client/petstore/typescript/tests/default/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptPestoreClientTests + TypeScriptPetstoreClientTests pom 1.0-SNAPSHOT TS Petstore Test Client diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index df08272870f4..1cbc0f11b67c 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -1,7 +1,5 @@ import * as petstore from "ts-petstore-client"; -import {map} from 'rxjs/operators'; - import { expect} from "chai"; import * as FormData from "form-data"; @@ -18,7 +16,7 @@ for (let libName in libs) { let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).subscribe((resp: petstore.http.ResponseContext) => { + lib.send(requestContext).toPromise().then((resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["headers"]).to.exist; @@ -41,7 +39,7 @@ for (let libName in libs) { formData.append("testFile", Buffer.from("abc"), "fileName.json"); requestContext.setBody(formData); - lib.send(requestContext).subscribe( + lib.send(requestContext).toPromise().then( (resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); @@ -61,7 +59,7 @@ for (let libName in libs) { let requestContext = new petstore.http.RequestContext("http://httpbin.org/cookies", petstore.http.HttpMethod.GET); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).subscribe( + lib.send(requestContext).toPromise().then( (resp: petstore.http.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index f212e11e31f0..356c53ecec6f 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -4,21 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", - "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" - } - } - }, "@types/jsdom": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-12.2.3.tgz", @@ -52,123 +37,178 @@ "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" }, - "@types/rx": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", - "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", - "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*", - "@types/rx-lite": "*", - "@types/rx-lite-aggregates": "*", - "@types/rx-lite-async": "*", - "@types/rx-lite-backpressure": "*", - "@types/rx-lite-coincidence": "*", - "@types/rx-lite-experimental": "*", - "@types/rx-lite-joinpatterns": "*", - "@types/rx-lite-testing": "*", - "@types/rx-lite-time": "*", - "@types/rx-lite-virtualtime": "*" - } - }, - "@types/rx-core": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", - "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + "@types/tough-cookie": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", + "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==" }, - "@types/rx-core-binding": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", - "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "@webassemblyjs/ast": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz", + "integrity": "sha512-aJMfngIZ65+t71C3y2nBBg5FFG0Okt9m0XEgWZ7Ywgn1oMAT8cNwx00Uv1cQyHtidq0Xn94R4TAywO+LCQ+ZAQ==", "requires": { - "@types/rx-core": "*" + "@webassemblyjs/helper-module-context": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/wast-parser": "1.8.5" } }, - "@types/rx-lite": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", - "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "@webassemblyjs/floating-point-hex-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.8.5.tgz", + "integrity": "sha512-9p+79WHru1oqBh9ewP9zW95E3XAo+90oth7S5Re3eQnECGq59ly1Ri5tsIipKGpiStHsUYmY3zMLqtk3gTcOtQ==" + }, + "@webassemblyjs/helper-api-error": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.8.5.tgz", + "integrity": "sha512-Za/tnzsvnqdaSPOUXHyKJ2XI7PDX64kWtURyGiJJZKVEdFOsdKUCPTNEVFZq3zJ2R0G5wc2PZ5gvdTRFgm81zA==" + }, + "@webassemblyjs/helper-buffer": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.8.5.tgz", + "integrity": "sha512-Ri2R8nOS0U6G49Q86goFIPNgjyl6+oE1abW1pS84BuhP1Qcr5JqMwRFT3Ah3ADDDYGEgGs1iyb1DGX+kAi/c/Q==" + }, + "@webassemblyjs/helper-code-frame": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.8.5.tgz", + "integrity": "sha512-VQAadSubZIhNpH46IR3yWO4kZZjMxN1opDrzePLdVKAZ+DFjkGD/rf4v1jap744uPVU6yjL/smZbRIIJTOUnKQ==", "requires": { - "@types/rx-core": "*", - "@types/rx-core-binding": "*" + "@webassemblyjs/wast-printer": "1.8.5" } }, - "@types/rx-lite-aggregates": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", - "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "@webassemblyjs/helper-fsm": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.8.5.tgz", + "integrity": "sha512-kRuX/saORcg8se/ft6Q2UbRpZwP4y7YrWsLXPbbmtepKr22i8Z4O3V5QE9DbZK908dh5Xya4Un57SDIKwB9eow==" + }, + "@webassemblyjs/helper-module-context": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.8.5.tgz", + "integrity": "sha512-/O1B236mN7UNEU4t9X7Pj38i4VoU8CcMHyy3l2cV/kIF4U5KoHXDVqcDuOs1ltkac90IM4vZdHc52t1x8Yfs3g==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "mamacro": "^0.0.3" } }, - "@types/rx-lite-async": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", - "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "@webassemblyjs/helper-wasm-bytecode": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.8.5.tgz", + "integrity": "sha512-Cu4YMYG3Ddl72CbmpjU/wbP6SACcOPVbHN1dI4VJNJVgFwaKf1ppeFJrwydOG3NDHxVGuCfPlLZNyEdIYlQ6QQ==" + }, + "@webassemblyjs/helper-wasm-section": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.8.5.tgz", + "integrity": "sha512-VV083zwR+VTrIWWtgIUpqfvVdK4ff38loRmrdDBgBT8ADXYsEZ5mPQ4Nde90N3UYatHdYoDIFb7oHzMncI02tA==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5" } }, - "@types/rx-lite-backpressure": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", - "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "@webassemblyjs/ieee754": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.8.5.tgz", + "integrity": "sha512-aaCvQYrvKbY/n6wKHb/ylAJr27GglahUO89CcGXMItrOBqRarUMxWLJgxm9PJNuKULwN5n1csT9bYoMeZOGF3g==", "requires": { - "@types/rx-lite": "*" + "@xtuc/ieee754": "^1.2.0" } }, - "@types/rx-lite-coincidence": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", - "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "@webassemblyjs/leb128": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.8.5.tgz", + "integrity": "sha512-plYUuUwleLIziknvlP8VpTgO4kqNaH57Y3JnNa6DLpu/sGcP6hbVdfdX5aHAV716pQBKrfuU26BJK29qY37J7A==", "requires": { - "@types/rx-lite": "*" + "@xtuc/long": "4.2.2" } }, - "@types/rx-lite-experimental": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", - "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "@webassemblyjs/utf8": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.8.5.tgz", + "integrity": "sha512-U7zgftmQriw37tfD934UNInokz6yTmn29inT2cAetAsaU9YeVCveWEwhKL1Mg4yS7q//NGdzy79nlXh3bT8Kjw==" + }, + "@webassemblyjs/wasm-edit": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.8.5.tgz", + "integrity": "sha512-A41EMy8MWw5yvqj7MQzkDjU29K7UJq1VrX2vWLzfpRHt3ISftOXqrtojn7nlPsZ9Ijhp5NwuODuycSvfAO/26Q==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/helper-wasm-section": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5", + "@webassemblyjs/wasm-opt": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5", + "@webassemblyjs/wast-printer": "1.8.5" } }, - "@types/rx-lite-joinpatterns": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", - "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "@webassemblyjs/wasm-gen": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.8.5.tgz", + "integrity": "sha512-BCZBT0LURC0CXDzj5FXSc2FPTsxwp3nWcqXQdOZE4U7h7i8FqtFK5Egia6f9raQLpEKT1VL7zr4r3+QX6zArWg==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/ieee754": "1.8.5", + "@webassemblyjs/leb128": "1.8.5", + "@webassemblyjs/utf8": "1.8.5" } }, - "@types/rx-lite-testing": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", - "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "@webassemblyjs/wasm-opt": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.8.5.tgz", + "integrity": "sha512-HKo2mO/Uh9A6ojzu7cjslGaHaUU14LdLbGEKqTR7PBKwT6LdPtLLh9fPY33rmr5wcOMrsWDbbdCHq4hQUdd37Q==", "requires": { - "@types/rx-lite-virtualtime": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5" } }, - "@types/rx-lite-time": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", - "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "@webassemblyjs/wasm-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.8.5.tgz", + "integrity": "sha512-pi0SYE9T6tfcMkthwcgCpL0cM9nRYr6/6fjgDtL6q/ZqKHdMWvxitRi5JcZ7RI4SNJJYnYNaWy5UUrHQy998lw==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-api-error": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/ieee754": "1.8.5", + "@webassemblyjs/leb128": "1.8.5", + "@webassemblyjs/utf8": "1.8.5" } }, - "@types/rx-lite-virtualtime": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", - "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "@webassemblyjs/wast-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.8.5.tgz", + "integrity": "sha512-daXC1FyKWHF1i11obK086QRlsMsY4+tIOKgBqI1lxAnkp9xe9YMcgOxm9kLe+ttjs5aWV2KKE1TWJCN57/Btsg==", "requires": { - "@types/rx-lite": "*" + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/floating-point-hex-parser": "1.8.5", + "@webassemblyjs/helper-api-error": "1.8.5", + "@webassemblyjs/helper-code-frame": "1.8.5", + "@webassemblyjs/helper-fsm": "1.8.5", + "@xtuc/long": "4.2.2" } }, - "@types/tough-cookie": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", - "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==" + "@webassemblyjs/wast-printer": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.8.5.tgz", + "integrity": "sha512-w0U0pD4EhlnvRyeJzBqaVSJAo9w/ce7/WPogeXLzGkO6hzhr4GnQIZ4W4uUt5b9ooAaXPtnXlj0gzsXEOUNYMg==", + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/wast-parser": "1.8.5", + "@xtuc/long": "4.2.2" + } + }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==" + }, + "@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" }, "abab": { "version": "2.0.0", @@ -228,6 +268,11 @@ "uri-js": "^4.2.2" } }, + "ajv-errors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==" + }, "ajv-keywords": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", @@ -248,6 +293,30 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -259,20 +328,17 @@ "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=" }, "array-equal": { "version": "1.0.0", @@ -282,8 +348,7 @@ "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" }, "arrify": { "version": "1.0.1", @@ -298,6 +363,40 @@ "safer-buffer": "~2.1.0" } }, + "asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", + "requires": { + "object-assign": "^4.1.1", + "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "requires": { + "inherits": "2.0.1" + } + } + } + }, "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", @@ -306,8 +405,12 @@ "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" + }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==" }, "async-limiter": { "version": "1.0.0", @@ -322,8 +425,7 @@ "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, "aws-sign2": { "version": "0.7.0", @@ -376,7 +478,6 @@ "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -391,7 +492,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, "requires": { "is-descriptor": "^1.0.0" } @@ -400,7 +500,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -409,7 +508,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -418,7 +516,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -427,6 +524,11 @@ } } }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -438,8 +540,22 @@ "big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==" + }, + "bluebird": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.1.tgz", + "integrity": "sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==" + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, "brace-expansion": { "version": "1.1.11", @@ -454,7 +570,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -472,28 +587,166 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } } } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, "browser-process-hrtime": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" }, + "browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "requires": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "requires": { + "pako": "~1.0.5" + } + }, + "buffer": { + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" + }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" + }, + "cacache": { + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz", + "integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==", + "requires": { + "bluebird": "^3.5.5", + "chownr": "^1.1.1", + "figgy-pudding": "^3.5.1", + "glob": "^7.1.4", + "graceful-fs": "^4.1.15", + "infer-owner": "^1.0.3", + "lru-cache": "^5.1.1", + "mississippi": "^3.0.0", + "mkdirp": "^0.5.1", + "move-concurrently": "^1.0.1", + "promise-inflight": "^1.0.1", + "rimraf": "^2.6.3", + "ssri": "^6.0.1", + "unique-filename": "^1.1.1", + "y18n": "^4.0.0" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + } + } + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -519,6 +772,11 @@ "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -557,6 +815,47 @@ "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" }, + "chokidar": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } + }, + "chownr": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + }, + "chrome-trace-event": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz", + "integrity": "sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ==", + "requires": { + "tslib": "^1.9.0" + } + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -566,7 +865,6 @@ "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -578,7 +876,6 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, "requires": { "is-descriptor": "^0.1.0" } @@ -598,6 +895,41 @@ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -607,7 +939,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -644,11 +975,15 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==" }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=" + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, "concat-map": { "version": "0.0.1", @@ -666,17 +1001,73 @@ "typedarray": "^0.0.6" } }, + "console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==" + }, + "constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=" + }, + "copy-concurrently": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", + "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", + "requires": { + "aproba": "^1.1.1", + "fs-write-stream-atomic": "^1.0.8", + "iferr": "^0.1.5", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.0" + } + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "create-ecdh": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, + "create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "requires": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "requires": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", @@ -687,6 +1078,24 @@ "which": "^1.2.9" } }, + "crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + } + }, "cssom": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz", @@ -700,6 +1109,11 @@ "cssom": "0.3.x" } }, + "cyclist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", + "integrity": "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=" + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -726,11 +1140,15 @@ "ms": "^2.1.1" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, "deep-is": { "version": "0.1.3", @@ -741,7 +1159,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -751,7 +1168,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -760,7 +1176,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -769,7 +1184,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -783,11 +1197,35 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "des.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", + "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, + "diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -796,6 +1234,11 @@ "esutils": "^2.0.2" } }, + "domain-browser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==" + }, "domexception": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", @@ -804,6 +1247,17 @@ "webidl-conversions": "^4.0.2" } }, + "duplexify": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", + "requires": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + } + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -813,17 +1267,42 @@ "safer-buffer": "^2.1.0" } }, + "elliptic": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz", + "integrity": "sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" + }, "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", - "dev": true + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } }, "enhanced-resolve": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", "integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==", - "dev": true, "requires": { "graceful-fs": "^4.1.2", "memory-fs": "^0.4.0", @@ -834,7 +1313,6 @@ "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", - "dev": true, "requires": { "prr": "~1.0.1" } @@ -1006,11 +1484,52 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" }, + "events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", + "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==" + }, + "evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "requires": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + } + } + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, "requires": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -1025,7 +1544,6 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, "requires": { "ms": "2.0.0" } @@ -1034,7 +1552,6 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, "requires": { "is-descriptor": "^0.1.0" } @@ -1043,7 +1560,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } @@ -1051,11 +1567,18 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" } } }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -1065,7 +1588,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -1075,7 +1597,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, "requires": { "is-plain-object": "^2.0.4" } @@ -1096,7 +1617,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, "requires": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -1112,7 +1632,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, "requires": { "is-descriptor": "^1.0.0" } @@ -1121,7 +1640,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } @@ -1130,7 +1648,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -1139,7 +1656,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -1148,7 +1664,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -1211,6 +1726,11 @@ "pend": "~1.2.0" } }, + "figgy-pudding": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", + "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==" + }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -1232,7 +1752,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -1244,29 +1763,65 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } } } }, - "flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "^3.0.0" + } + }, + "findup-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", + "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", "write": "^0.2.1" } }, + "flush-write-stream": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", + "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", + "requires": { + "inherits": "^2.0.3", + "readable-stream": "^2.3.6" + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" }, "forever-agent": { "version": "0.6.1", @@ -1274,9 +1829,9 @@ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -1287,26 +1842,519 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, "requires": { "map-cache": "^0.2.2" } }, + "from2": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "requires": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.0" + } + }, + "fs-write-stream-atomic": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", + "integrity": "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk=", + "requires": { + "graceful-fs": "^4.1.2", + "iferr": "^0.1.5", + "imurmurhash": "^0.1.4", + "readable-stream": "1 || 2" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "optional": true, + "requires": { + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "bundled": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "bundled": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true + }, + "minipass": { + "version": "2.3.5", + "bundled": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "bundled": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.1", + "bundled": true, + "optional": true + }, + "needle": { + "version": "2.3.0", + "bundled": true, + "optional": true, + "requires": { + "debug": "^4.1.0", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.12.0", + "bundled": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.6", + "bundled": true, + "optional": true + }, + "npm-packlist": { + "version": "1.4.1", + "bundled": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.3", + "bundled": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "optional": true + }, + "semver": { + "version": "5.7.0", + "bundled": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "optional": true + }, + "tar": { + "version": "4.4.8", + "bundled": true, + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + }, + "yallist": { + "version": "3.0.3", + "bundled": true + } + } + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "requires": { + "pump": "^3.0.0" + } + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=" }, "getpass": { "version": "0.1.7", @@ -1329,6 +2377,57 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "global-modules": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", + "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", + "requires": { + "global-prefix": "^3.0.0" + }, + "dependencies": { + "global-prefix": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", + "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", + "requires": { + "ini": "^1.3.5", + "kind-of": "^6.0.2", + "which": "^1.3.1" + } + } + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -1370,7 +2469,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -1381,7 +2479,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -1391,13 +2488,40 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } } } }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", @@ -1424,6 +2548,11 @@ "sshpk": "^1.7.0" } }, + "https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" + }, "https-proxy-agent": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", @@ -1451,16 +2580,40 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "iferr": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", + "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=" + }, "ignore": { "version": "3.3.10", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" }, + "import-local": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", + "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "requires": { + "pkg-dir": "^3.0.0", + "resolve-cwd": "^2.0.0" + } + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" }, + "infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==" + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1475,6 +2628,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, "inquirer": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", @@ -1496,11 +2654,20 @@ "through": "^2.3.6" } }, + "interpret": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==" + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==" + }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, "requires": { "kind-of": "^3.0.2" }, @@ -1509,24 +2676,29 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } } } }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "requires": { + "binary-extensions": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, "requires": { "kind-of": "^3.0.2" }, @@ -1535,7 +2707,6 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } @@ -1546,7 +2717,6 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -1556,27 +2726,37 @@ "kind-of": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==" } } }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, "requires": { "kind-of": "^3.0.2" }, @@ -1585,7 +2765,6 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } @@ -1596,7 +2775,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, "requires": { "isobject": "^3.0.1" } @@ -1611,6 +2789,11 @@ "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==" }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1619,8 +2802,12 @@ "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" }, "isarray": { "version": "1.0.0", @@ -1635,8 +2822,7 @@ "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, "isstream": { "version": "0.1.2", @@ -1714,6 +2900,11 @@ } } }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -1738,7 +2929,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, "requires": { "minimist": "^1.2.0" }, @@ -1746,8 +2936,7 @@ "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } }, @@ -1765,8 +2954,15 @@ "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "requires": { + "invert-kv": "^2.0.0" + } }, "levn": { "version": "0.3.0", @@ -1777,17 +2973,30 @@ "type-check": "~0.3.2" } }, + "loader-runner": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", + "integrity": "sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw==" + }, "loader-utils": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dev": true, "requires": { "big.js": "^5.2.2", "emojis-list": "^2.0.0", "json5": "^1.0.1" } }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -1807,31 +3016,77 @@ "yallist": "^2.1.2" } }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, "make-error": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==" }, + "mamacro": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/mamacro/-/mamacro-0.0.3.tgz", + "integrity": "sha512-qMEwh+UujcQ+kbz3T6V+wAmO2U8veoq2w+3wY8MquqwVA3jChfwY+Tk52GZKDfACEPjuZ7r2oJLejwpt8jtwTA==" + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "requires": { + "p-defer": "^1.0.0" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, "requires": { "object-visit": "^1.0.0" } }, + "md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + } + } + }, "memory-fs": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", - "dev": true, "requires": { "errno": "^0.1.3", "readable-stream": "^2.0.1" @@ -1841,7 +3096,6 @@ "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -1858,6 +3112,15 @@ "to-regex": "^3.0.2" } }, + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, "mime": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", @@ -1881,6 +3144,16 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -1894,11 +3167,27 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, + "mississippi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", + "integrity": "sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==", + "requires": { + "concat-stream": "^1.5.0", + "duplexify": "^3.4.2", + "end-of-stream": "^1.1.0", + "flush-write-stream": "^1.0.0", + "from2": "^2.1.0", + "parallel-transform": "^1.1.0", + "pump": "^3.0.0", + "pumpify": "^1.3.3", + "stream-each": "^1.1.0", + "through2": "^2.0.0" + } + }, "mixin-deep": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", - "dev": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -1908,7 +3197,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, "requires": { "is-plain-object": "^2.0.4" } @@ -1923,6 +3211,19 @@ "minimist": "0.0.8" } }, + "move-concurrently": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", + "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", + "requires": { + "aproba": "^1.1.1", + "copy-concurrently": "^1.0.0", + "fs-write-stream-atomic": "^1.0.8", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.3" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -1933,11 +3234,16 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -1957,6 +3263,53 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" + }, + "node-libs-browser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", + "integrity": "sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==", + "requires": { + "assert": "^1.1.1", + "browserify-zlib": "^0.2.0", + "buffer": "^4.3.0", + "console-browserify": "^1.1.0", + "constants-browserify": "^1.0.0", + "crypto-browserify": "^3.11.0", + "domain-browser": "^1.1.1", + "events": "^3.0.0", + "https-browserify": "^1.0.0", + "os-browserify": "^0.3.0", + "path-browserify": "0.0.1", + "process": "^0.11.10", + "punycode": "^1.2.4", + "querystring-es3": "^0.2.0", + "readable-stream": "^2.3.3", + "stream-browserify": "^2.0.1", + "stream-http": "^2.7.2", + "string_decoder": "^1.0.0", + "timers-browserify": "^2.0.4", + "tty-browserify": "0.0.0", + "url": "^0.11.0", + "util": "^0.11.0", + "vm-browserify": "^1.0.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, "node-qunit-puppeteer": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/node-qunit-puppeteer/-/node-qunit-puppeteer-1.0.12.tgz", @@ -1971,6 +3324,19 @@ "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.6.0.tgz", "integrity": "sha512-XAgTL05z75ptd7JSVejH1a2Dm1zmXYhuDr9l230Qk6Z7/7GPcnAs/UyJJ4ggsXSvWil8iOzwQLW0zuGUvHpG8g==" }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "^2.0.0" + } + }, "nwsapi": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", @@ -1990,7 +3356,6 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -2001,7 +3366,6 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, "requires": { "is-descriptor": "^0.1.0" } @@ -2010,7 +3374,6 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } @@ -2021,7 +3384,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, "requires": { "isobject": "^3.0.0" } @@ -2030,7 +3392,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, "requires": { "isobject": "^3.0.1" } @@ -2064,11 +3425,90 @@ "wordwrap": "~1.0.0" } }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=" + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=" + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==" + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "pako": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", + "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==" + }, + "parallel-transform": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.2.0.tgz", + "integrity": "sha512-P2vSmIu38uIlvdcU7fDkyrxj33gTUy/ABO5ZUbGowxNCopBq/OoD42bP4UmMrJoPyk4Uqf0mu3mtWBhHCZD8yg==", + "requires": { + "cyclist": "^1.0.1", + "inherits": "^2.0.3", + "readable-stream": "^2.1.5" + } + }, + "parse-asn1": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", + "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -2082,8 +3522,22 @@ "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" + }, + "path-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==" + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=" + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" }, "path-is-absolute": { "version": "1.0.1", @@ -2095,11 +3549,28 @@ "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, + "pbkdf2": { + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "requires": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -2110,6 +3581,19 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "requires": { + "find-up": "^3.0.0" + } + }, "pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", @@ -2123,14 +3607,18 @@ "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -2141,6 +3629,11 @@ "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, + "promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" + }, "proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", @@ -2149,8 +3642,7 @@ "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "dev": true + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" }, "pseudomap": { "version": "1.0.2", @@ -2162,6 +3654,49 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" }, + "public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "pumpify": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", + "requires": { + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" + }, + "dependencies": { + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + } + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -2187,6 +3722,16 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" + }, "qunit": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/qunit/-/qunit-2.9.2.tgz", @@ -2199,6 +3744,23 @@ "resolve": "1.9.0" } }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "requires": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -2213,11 +3775,20 @@ "util-deprecate": "~1.0.1" } }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -2228,17 +3799,20 @@ "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=" + }, "repeat-element": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==" }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" }, "request": { "version": "2.88.0", @@ -2267,6 +3841,16 @@ "uuid": "^3.3.2" }, "dependencies": { + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -2301,6 +3885,16 @@ "tough-cookie": "^2.3.3" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -2323,6 +3917,42 @@ "path-parse": "^1.0.6" } }, + "resolve-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", + "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", + "requires": { + "resolve-from": "^3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=" + } + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + }, + "dependencies": { + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + } + } + }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", @@ -2331,8 +3961,7 @@ "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=" }, "restore-cursor": { "version": "2.0.0", @@ -2346,8 +3975,7 @@ "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" }, "rewire": { "version": "4.0.1", @@ -2365,6 +3993,15 @@ "glob": "^7.1.3" } }, + "ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", @@ -2373,6 +4010,14 @@ "is-promise": "^2.1.0" } }, + "run-queue": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", + "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", + "requires": { + "aproba": "^1.1.1" + } + }, "rx-lite": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", @@ -2386,14 +4031,6 @@ "rx-lite": "*" } }, - "rxjs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", - "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -2403,7 +4040,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, "requires": { "ret": "~0.1.10" } @@ -2421,16 +4057,42 @@ "xmlchars": "^1.3.1" } }, + "schema-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", + "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", + "requires": { + "ajv": "^6.1.0", + "ajv-errors": "^1.0.0", + "ajv-keywords": "^3.1.0" + }, + "dependencies": { + "ajv-keywords": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==" + } + } + }, "semver": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, + "serialize-javascript": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", + "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", - "dev": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -2442,13 +4104,26 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } } } }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -2479,7 +4154,6 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -2495,7 +4169,6 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, "requires": { "ms": "2.0.0" } @@ -2504,7 +4177,6 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, "requires": { "is-descriptor": "^0.1.0" } @@ -2513,7 +4185,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } @@ -2521,14 +4192,12 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" } } }, @@ -2536,7 +4205,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -2547,7 +4215,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, "requires": { "is-descriptor": "^1.0.0" } @@ -2556,7 +4223,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -2565,7 +4231,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, "requires": { "kind-of": "^6.0.0" } @@ -2574,7 +4239,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -2587,7 +4251,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, "requires": { "kind-of": "^3.2.0" }, @@ -2596,24 +4259,26 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } } } }, + "source-list-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", + "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==" + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "source-map-resolve": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, "requires": { "atob": "^2.1.1", "decode-uri-component": "^0.2.0", @@ -2640,14 +4305,12 @@ "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, "requires": { "extend-shallow": "^3.0.0" } @@ -2673,11 +4336,18 @@ "tweetnacl": "~0.14.0" } }, + "ssri": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", + "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "requires": { + "figgy-pudding": "^3.5.1" + } + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -2687,7 +4357,6 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, "requires": { "is-descriptor": "^0.1.0" } @@ -2699,6 +4368,41 @@ "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" }, + "stream-browserify": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", + "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", + "requires": { + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" + } + }, + "stream-each": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", + "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", + "requires": { + "end-of-stream": "^1.1.0", + "stream-shift": "^1.0.0" + } + }, + "stream-http": { + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", + "requires": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.3.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" + } + }, + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -2736,6 +4440,11 @@ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -2790,8 +4499,49 @@ "tapable": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", - "dev": true + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==" + }, + "terser": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz", + "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==", + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "source-map-support": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", + "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } + } + }, + "terser-webpack-plugin": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz", + "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==", + "requires": { + "cacache": "^12.0.2", + "find-cache-dir": "^2.1.0", + "is-wsl": "^1.1.0", + "schema-utils": "^1.0.0", + "serialize-javascript": "^1.7.0", + "source-map": "^0.6.1", + "terser": "^4.1.2", + "webpack-sources": "^1.4.0", + "worker-farm": "^1.7.0" + } }, "text-table": { "version": "0.2.0", @@ -2803,6 +4553,23 @@ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, + "timers-browserify": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.11.tgz", + "integrity": "sha512-60aV6sgJ5YEbzUdn9c8kYGIqOubPoUdqQCul3SBAsRCZ40s6Y5cMcrW4dt3/k/EsbLVJNl9n6Vz3fTc+k2GeKQ==", + "requires": { + "setimmediate": "^1.0.4" + } + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -2811,11 +4578,15 @@ "os-tmpdir": "~1.0.2" } }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=" + }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, "requires": { "kind-of": "^3.0.2" }, @@ -2824,7 +4595,6 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, "requires": { "is-buffer": "^1.1.5" } @@ -2835,7 +4605,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -2847,7 +4616,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -2910,14 +4678,12 @@ "ts-petstore-client": { "version": "file:../../builds/jquery", "requires": { - "@types/form-data": "^2.2.1", "@types/jquery": "^3.3.29", - "@types/rx": "^4.1.1", + "@types/node": "*", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "form-data": "^2.3.2", + "form-data": "^2.5.0", "jquery": "^3.4.1", - "rxjs": "^6.4.0", "url-parse": "^1.4.3" }, "dependencies": { @@ -3052,7 +4818,7 @@ "bundled": true }, "combined-stream": { - "version": "1.0.7", + "version": "1.0.8", "bundled": true, "requires": { "delayed-stream": "~1.0.0" @@ -3067,7 +4833,7 @@ "bundled": true }, "form-data": { - "version": "2.3.3", + "version": "2.5.1", "bundled": true, "requires": { "asynckit": "^0.4.0", @@ -3137,6 +4903,11 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -3173,7 +4944,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", - "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -3185,7 +4955,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, "requires": { "is-extendable": "^0.1.0" } @@ -3194,7 +4963,6 @@ "version": "0.4.3", "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -3204,11 +4972,26 @@ } } }, + "unique-filename": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", + "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", + "requires": { + "unique-slug": "^2.0.0" + } + }, + "unique-slug": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", + "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", + "requires": { + "imurmurhash": "^0.1.4" + } + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -3218,7 +5001,6 @@ "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -3229,7 +5011,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, "requires": { "isarray": "1.0.0" } @@ -3239,11 +5020,15 @@ "has-values": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=" } } }, + "upath": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -3255,14 +5040,36 @@ "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=" + }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + } + } }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" + }, + "util": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz", + "integrity": "sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ==", + "requires": { + "inherits": "2.0.3" + } }, "util-deprecate": { "version": "1.0.2", @@ -3274,6 +5081,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, + "v8-compile-cache": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz", + "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==" + }, "v8flags": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", @@ -3292,6 +5104,11 @@ "extsprintf": "^1.2.0" } }, + "vm-browserify": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", + "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==" + }, "w3c-hr-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", @@ -3310,11 +5127,132 @@ "xml-name-validator": "^3.0.0" } }, + "watchpack": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", + "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", + "requires": { + "chokidar": "^2.0.2", + "graceful-fs": "^4.1.2", + "neo-async": "^2.5.0" + } + }, "webidl-conversions": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" }, + "webpack": { + "version": "4.41.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.41.2.tgz", + "integrity": "sha512-Zhw69edTGfbz9/8JJoyRQ/pq8FYUoY0diOXqW0T6yhgdhCv6wr0hra5DwwWexNRns2Z2+gsnrNcbe9hbGBgk/A==", + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-module-context": "1.8.5", + "@webassemblyjs/wasm-edit": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5", + "acorn": "^6.2.1", + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^4.1.0", + "eslint-scope": "^4.0.3", + "json-parse-better-errors": "^1.0.2", + "loader-runner": "^2.4.0", + "loader-utils": "^1.2.3", + "memory-fs": "^0.4.1", + "micromatch": "^3.1.10", + "mkdirp": "^0.5.1", + "neo-async": "^2.6.1", + "node-libs-browser": "^2.2.1", + "schema-utils": "^1.0.0", + "tapable": "^1.1.3", + "terser-webpack-plugin": "^1.4.1", + "watchpack": "^1.6.0", + "webpack-sources": "^1.4.1" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==" + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==" + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + } + } + }, + "webpack-cli": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.10.tgz", + "integrity": "sha512-u1dgND9+MXaEt74sJR4PR7qkPxXUSQ0RXYq8x1L6Jg1MYVEmGPrH6Ah6C4arD4r0J1P5HKjRqpab36k0eIzPqg==", + "requires": { + "chalk": "2.4.2", + "cross-spawn": "6.0.5", + "enhanced-resolve": "4.1.0", + "findup-sync": "3.0.0", + "global-modules": "2.0.0", + "import-local": "2.0.0", + "interpret": "1.2.0", + "loader-utils": "1.2.3", + "supports-color": "6.1.0", + "v8-compile-cache": "2.0.3", + "yargs": "13.2.4" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "webpack-sources": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", + "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + }, "whatwg-encoding": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", @@ -3346,11 +5284,67 @@ "isexe": "^2.0.0" } }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" }, + "worker-farm": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz", + "integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==", + "requires": { + "errno": "~0.1.7" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -3382,11 +5376,73 @@ "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-1.3.1.tgz", "integrity": "sha512-tGkGJkN8XqCod7OT+EvGYK5Z4SfDQGD30zAa58OcnAa0RRWgzUEK72tkXhsX1FZd+rgnhRxFtmO+ihkp8LHSkw==" }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" }, + "yargs": { + "version": "13.2.4", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.4.tgz", + "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, "yauzl": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/client/petstore/typescript/tests/jquery/package.json index c2f0c14eb111..f83edaf156d3 100644 --- a/samples/client/petstore/typescript/tests/jquery/package.json +++ b/samples/client/petstore/typescript/tests/jquery/package.json @@ -1,20 +1,19 @@ { "private": true, "dependencies": { - "@types/form-data": "^2.2.1", "@types/jsdom": "^12.2.3", "@types/qunit": "^2.9.0", "@types/rewire": "^2.5.28", - "@types/rx": "^4.1.1", - "form-data": "^2.3.2", + "form-data": "^2.5.1", "jsdom": "^15.0.0", "node-qunit-puppeteer": "^1.0.12", "qunit": "^2.9.2", "requirejs": "^2.3.6", "rewire": "^4.0.1", - "rxjs": "^6.4.0", "ts-node": "^3.3.0", - "ts-petstore-client": "file:../../builds/jquery" + "ts-petstore-client": "file:../../builds/jquery", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "test": "node ./dist/test-runner.js", diff --git a/samples/client/petstore/typescript/tests/jquery/pom.xml b/samples/client/petstore/typescript/tests/jquery/pom.xml index ed382e65631d..c8fea0f2c067 100644 --- a/samples/client/petstore/typescript/tests/jquery/pom.xml +++ b/samples/client/petstore/typescript/tests/jquery/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptPestoreClientTests + TypeScriptPetstoreClientTests pom 1.0-SNAPSHOT TS Petstore Test Client diff --git a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts index d2f80876bb1a..8f46bc90c70e 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts +++ b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts @@ -17,7 +17,7 @@ for (let libName in libs) { let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); return new Promise((resolve, reject) => { - lib.send(requestContext).subscribe((resp: petstore.http.ResponseContext) => { + lib.send(requestContext).toPromise().then((resp: petstore.http.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); let body = JSON.parse(resp.body); assert.ok(body["headers"]); @@ -43,7 +43,7 @@ for (let libName in libs) { requestContext.setBody(formData); return new Promise((resolve, reject) => { - lib.send(requestContext).subscribe( + lib.send(requestContext).toPromise().then( (resp: petstore.http.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); let body = JSON.parse(resp.body); @@ -66,7 +66,7 @@ for (let libName in libs) { requestContext.addCookie("test", "test2"); return new Promise((resolve, reject) => { try { - lib.send(requestContext).subscribe( + lib.send(requestContext).toPromise().then( (resp: petstore.http.ResponseContext) => { assert.ok(false, "Expected this request to fail!") reject("Successful request with Cookie Header!") From 9afb8ff12a2a76ace737dd7f249ae396ef3975c6 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Sat, 18 Jan 2020 12:31:27 +0100 Subject: [PATCH 57/85] Typescript refactor: Platform select for browser and node (#4500) * Use string form of filename parameter This works for the form-data library and is also compatible with the browser FormData object. * Add new option to select platform node or browser When no platform is selected, a default is chosen by the framework option and likewise the file data type option is implied by the platform. * Remove redundant import of node dns module * Only use form-data library for node platform * Generate npm package from npmName option * Use method convertPropertyToBooleanAndWriteBack * Generate typescript samples with ensure-up-to-date --- bin/typescript.sh | 4 +- bin/utils/ensure-up-to-date | 1 + docs/generators/typescript.md | 1 + .../languages/TypeScriptClientCodegen.java | 67 ++++++++++++------- .../resources/typescript/api/api.mustache | 6 +- .../resources/typescript/http/http.mustache | 4 ++ .../resources/typescript/http/jquery.mustache | 5 +- .../resources/typescript/package.mustache | 15 +++-- .../builds/default/.openapi-generator/VERSION | 2 +- .../typescript/builds/default/apis/PetApi.ts | 2 +- .../typescript/builds/default/package.json | 11 ++- .../builds/jquery/.openapi-generator/VERSION | 2 +- .../typescript/builds/jquery/apis/PetApi.ts | 3 +- .../typescript/builds/jquery/apis/StoreApi.ts | 1 - .../typescript/builds/jquery/apis/UserApi.ts | 1 - .../typescript/builds/jquery/http/http.ts | 2 - .../typescript/builds/jquery/http/jquery.ts | 2 - .../builds/jquery/package-lock.json | 46 ------------- .../typescript/builds/jquery/package.json | 9 +-- .../typescript/tests/jquery/package-lock.json | 2 - .../tests/jquery/test/http/jquery.test.ts | 2 - 21 files changed, 81 insertions(+), 107 deletions(-) diff --git a/bin/typescript.sh b/bin/typescript.sh index 8a0de14cc0a8..a94b40df1140 100755 --- a/bin/typescript.sh +++ b/bin/typescript.sh @@ -28,10 +28,10 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" echo "Creating default (fetch) client!" -ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default $@" +ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default --additional-properties=platform=node,npmName=ts-petstore-client $@" java $JAVA_OPTS -jar $executable $ags echo "Creating jquery client!" -ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,fileContentDataType=Blob $@" +ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 9b1eec0774b7..317ff3295c8f 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -50,6 +50,7 @@ declare -a samples=( #"${root}/bin/php-slim4-server-petstore.sh" "${root}/bin/php-ze-ph-petstore-server.sh" "${root}/bin/openapi3/php-petstore.sh" +"${root}/bin/typescript.sh" "${root}/bin/typescript-angularjs-petstore.sh" "${root}/bin/typescript-angular-petstore-all.sh" "${root}/bin/typescript-aurelia-petstore.sh" diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 11ebf4ce2910..c1599ef50218 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -13,4 +13,5 @@ sidebar_label: typescript |supportsES6|Generate code that conforms to ES6.| |false| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| |useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false| +|platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.| |null| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index b65346fbcbd9..40e7103019a5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -46,6 +46,9 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String FRAMEWORK_SWITCH = "framework"; private static final String FRAMEWORK_SWITCH_DESC = "Specify the framework which should be used in the client code."; private static final String[] FRAMEWORKS = { "fetch-api", "jquery" }; + private static final String PLATFORM_SWITCH = "platform"; + private static final String PLATFORM_SWITCH_DESC = "Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise."; + private static final String[] PLATFORMS = { "browser", "node" }; private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)"; private static final String USE_RXJS_SWITCH = "useRxJS"; @@ -142,6 +145,14 @@ public TypeScriptClientCodegen() { } frameworkOption.defaultValue(FRAMEWORKS[0]); + cliOptions.add(new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC)); + CliOption platformOption = new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC); + for (String option: TypeScriptClientCodegen.PLATFORMS) { + // TODO: improve description? + platformOption.addEnum(option, option); + } + platformOption.defaultValue(PLATFORMS[0]); + cliOptions.add(frameworkOption); @@ -191,16 +202,17 @@ public CodegenType getTag() { @Override public Map postProcessSupportingFileData(Map objs) { + final Object propFramework = additionalProperties.get(FRAMEWORK_SWITCH); + Map frameworks = new HashMap<>(); for (String framework: FRAMEWORKS) { - frameworks.put(framework, framework.equals(additionalProperties.get(FRAMEWORK_SWITCH))); + frameworks.put(framework, framework.equals(propFramework)); } - objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH)); + objs.put("framework", propFramework); objs.put("frameworks", frameworks); - - Object propDataType = additionalProperties.get(FILE_CONTENT_DATA_TYPE); - objs.put("fileContentDataType", propDataType == null ? "Buffer" : propDataType); - + + objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE)); + return objs; } @@ -695,33 +707,40 @@ public void processOpts() { setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING)); } - if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) { - // convert to boolean - additionalProperties.put(CodegenConstants.SUPPORTS_ES6, - Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString()) - ); - } + convertPropertyToBooleanAndWriteBack(CodegenConstants.SUPPORTS_ES6); // change package names apiPackage = this.apiPackage + ".apis"; modelPackage = this.modelPackage + ".models"; testPackage = this.testPackage + ".tests"; - if (additionalProperties.containsKey(FRAMEWORK_SWITCH)) { - supportingFiles.add(new SupportingFile("generators/" + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", "index.ts")); - } else { - additionalProperties.put(FRAMEWORK_SWITCH, FRAMEWORKS[0]); - supportingFiles.add(new SupportingFile("generators" + File.separator + FRAMEWORKS[0] + ".mustache", "index.ts")); - } + additionalProperties.putIfAbsent(FRAMEWORK_SWITCH, FRAMEWORKS[0]); + supportingFiles.add(new SupportingFile( + "generators" + File.separator + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", + "index.ts" + )); + String httpLibName = this.getHttpLibForFramework(additionalProperties.get(FRAMEWORK_SWITCH).toString()); - supportingFiles.add(new SupportingFile("http" + File.separator + httpLibName + ".mustache", "http", httpLibName + ".ts")); + supportingFiles.add(new SupportingFile( + "http" + File.separator + httpLibName + ".mustache", + "http", httpLibName + ".ts" + )); - boolean useRxJS = false; - if (additionalProperties.containsKey(USE_RXJS_SWITCH)) { - // convert to boolean - useRxJS = Boolean.valueOf(additionalProperties.get(USE_RXJS_SWITCH).toString()); - additionalProperties.put(USE_RXJS_SWITCH, useRxJS); + Object propPlatform = additionalProperties.get(PLATFORM_SWITCH); + if (propPlatform == null) { + propPlatform = "browser"; + additionalProperties.put("platform", propPlatform); } + + Map platforms = new HashMap<>(); + for (String platform: PLATFORMS) { + platforms.put(platform, platform.equals(propPlatform)); + } + additionalProperties.put("platforms", platforms); + + additionalProperties.putIfAbsent(FILE_CONTENT_DATA_TYPE, propPlatform.equals("node") ? "Buffer" : "Blob"); + + final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH); if (!useRxJS) { supportingFiles.add(new SupportingFile("rxjsStub.mustache", "", "rxjsStub.ts")); } diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index ed67714c2011..4ac32d6839d6 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -2,7 +2,11 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +{{#platforms}} +{{#node}} import * as FormData from "form-data"; +{{/node}} +{{/platforms}} import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; @@ -88,7 +92,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { localVarFormParams.append('{{baseName}}', {{paramName}} as any); {{/isFile}} {{#isFile}} - localVarFormParams.append('{{baseName}}', {{paramName}}.data, { "filename": {{paramName}}.name }); + localVarFormParams.append('{{baseName}}', {{paramName}}.data, {{paramName}}.name); {{/isFile}} } {{/isListContainer}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index a4b6edc4445a..9effd7704711 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -1,5 +1,9 @@ +{{#platforms}} +{{#node}} // TODO: evaluate if we can easily get rid of this library import * as FormData from "form-data"; +{{/node}} +{{/platforms}} // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index 4d641b17bb79..dd08009ff3a0 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -3,8 +3,11 @@ import * as e6p from 'es6-promise' import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; e6p.polyfill(); import * as $ from 'jquery'; +{{#platforms}} +{{#node}} import * as FormData from "form-data"; -import { resolve } from 'dns'; +{{/node}} +{{/platforms}} export class JQueryHttpLibrary implements HttpLibrary { diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 16087369be4d..ec0e6303f984 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -1,5 +1,5 @@ { - "name": "ts-petstore-client", + "name": "{{npmName}}", "version": "1.0.0", "description": "OpenAPI client for {{npmName}}", "author": "OpenAPI-Generator Contributors", @@ -7,8 +7,7 @@ "fetch", "typescript", "openapi-client", - "openapi-generator", - "{{npmName}}" + "openapi-generator" ], "license": "Unlicense", "main": "./dist/index.js", @@ -18,8 +17,6 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "es6-promise": "^4.2.4", - "@types/node": "*", {{#frameworks}} {{#fetch-api}} "isomorphic-fetch": "^2.2.1", @@ -30,11 +27,17 @@ "jquery": "^3.4.1", {{/jquery}} {{/frameworks}} - "btoa": "^1.2.1", + {{#platforms}} + {{#node}} + "@types/node": "*", "form-data": "^2.5.0", + {{/node}} + {{/platforms}} {{#useRxJS}} "rxjs": "^6.4.0", {{/useRxJS}} + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, "devDependencies": { diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION index 717311e32e3c..c3a2c7076fa8 100644 --- a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION @@ -1 +1 @@ -unset \ No newline at end of file +4.2.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 83904063a7dc..7f9e16f207a2 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -365,7 +365,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { } if (file !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('file', file.data, { "filename": file.name }); + localVarFormParams.append('file', file.data, file.name); } requestContext.setBody(localVarFormParams); diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index d1a961e18a0c..70b348648e12 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -1,14 +1,13 @@ { "name": "ts-petstore-client", "version": "1.0.0", - "description": "OpenAPI client for ", + "description": "OpenAPI client for ts-petstore-client", "author": "OpenAPI-Generator Contributors", "keywords": [ "fetch", "typescript", "openapi-client", - "openapi-generator", - "" + "openapi-generator" ], "license": "Unlicense", "main": "./dist/index.js", @@ -18,12 +17,12 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "es6-promise": "^4.2.4", - "@types/node": "*", "isomorphic-fetch": "^2.2.1", "@types/isomorphic-fetch": "0.0.34", - "btoa": "^1.2.1", + "@types/node": "*", "form-data": "^2.5.0", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, "devDependencies": { diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION index 717311e32e3c..c3a2c7076fa8 100644 --- a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION @@ -1 +1 @@ -unset \ No newline at end of file +4.2.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts index 83904063a7dc..31693b0eb4c3 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -2,7 +2,6 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; -import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; @@ -365,7 +364,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { } if (file !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('file', file.data, { "filename": file.name }); + localVarFormParams.append('file', file.data, file.name); } requestContext.setBody(localVarFormParams); diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index 55769fdc2491..4a6a03856459 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -2,7 +2,6 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; -import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts index b3040726a8f0..bff513b7807b 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -2,7 +2,6 @@ import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; -import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 0e5f142952dc..14c71de90df2 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -1,5 +1,3 @@ -// TODO: evaluate if we can easily get rid of this library -import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts index 3803cc7dbd55..30bd09f56caf 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -3,8 +3,6 @@ import * as e6p from 'es6-promise' import { from, Observable } from '../rxjsStub'; e6p.polyfill(); import * as $ from 'jquery'; -import * as FormData from "form-data"; -import { resolve } from 'dns'; export class JQueryHttpLibrary implements HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/client/petstore/typescript/builds/jquery/package-lock.json index d64ff033dae8..cdbe4eeddc48 100644 --- a/samples/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/client/petstore/typescript/builds/jquery/package-lock.json @@ -12,72 +12,26 @@ "@types/sizzle": "*" } }, - "@types/node": { - "version": "12.12.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", - "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" - }, "@types/sizzle": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, "btoa": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, "es6-promise": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, - "form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, "jquery": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" }, - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "requires": { - "mime-db": "1.40.0" - } - }, "querystringify": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", diff --git a/samples/client/petstore/typescript/builds/jquery/package.json b/samples/client/petstore/typescript/builds/jquery/package.json index fdcb5251e3c4..0fc169d48802 100644 --- a/samples/client/petstore/typescript/builds/jquery/package.json +++ b/samples/client/petstore/typescript/builds/jquery/package.json @@ -1,14 +1,13 @@ { "name": "ts-petstore-client", "version": "1.0.0", - "description": "OpenAPI client for ", + "description": "OpenAPI client for ts-petstore-client", "author": "OpenAPI-Generator Contributors", "keywords": [ "fetch", "typescript", "openapi-client", - "openapi-generator", - "" + "openapi-generator" ], "license": "Unlicense", "main": "./dist/index.js", @@ -18,12 +17,10 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "es6-promise": "^4.2.4", - "@types/node": "*", "@types/jquery": "^3.3.29", "jquery": "^3.4.1", "btoa": "^1.2.1", - "form-data": "^2.5.0", + "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, "devDependencies": { diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index 356c53ecec6f..f1ff014ed63d 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -4679,10 +4679,8 @@ "version": "file:../../builds/jquery", "requires": { "@types/jquery": "^3.3.29", - "@types/node": "*", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "form-data": "^2.5.0", "jquery": "^3.4.1", "url-parse": "^1.4.3" }, diff --git a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts index 8f46bc90c70e..1290d544cf0f 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts +++ b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts @@ -2,8 +2,6 @@ declare var QUnit: any; import * as petstore from "ts-petstore-client"; -import * as FormData from "form-data"; - let libs: { [key: string]: petstore.http.HttpLibrary } = { "jquery": new petstore.http.JQueryHttpLibrary() } From bfc14c82e5276ea2c08eb06a28e9c8ec25d03934 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 27 Apr 2020 01:12:35 +0200 Subject: [PATCH 58/85] Removed tab from DefaultCodegen --- .../src/main/java/org/openapitools/codegen/DefaultCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index a62ab388a600..914c59facc85 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3686,7 +3686,7 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { default: throw new RuntimeException("Invalid response code " + responseCode); } - r.isSuccessCode = r.code.startsWith("2"); + r.isSuccessCode = r.code.startsWith("2"); } Schema responseSchema; if (this.openAPI != null && this.openAPI.getComponents() != null) { From d704a4ffbac84c0be173e0d9577a05288c155108 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 2 May 2020 19:21:57 +0200 Subject: [PATCH 59/85] Readded missing change --- .../main/java/org/openapitools/codegen/DefaultCodegen.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 914c59facc85..f2ac1f45ce89 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3327,8 +3327,9 @@ protected void handleMethodResponse(Operation operation, op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation)); op.defaultResponse = toDefaultValue(responseSchema); op.returnType = cm.dataType; - op.hasReference = schemas.containsKey(op.returnBaseType); - + op.returnFormat = cm.dataFormat; + op.hasReference = schemas != null && schemas.containsKey(op.returnBaseType); + // lookup discriminator Schema schema = schemas.get(op.returnBaseType); if (schema != null) { From 5a2561f520e98273b97f9bcaf1400ceb5764f175 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 2 May 2020 22:03:56 +0200 Subject: [PATCH 60/85] Mark typescript client codegen as experimental --- .../codegen/languages/TypeScriptClientCodegen.java | 8 ++++++-- .../typescript/builds/default/.openapi-generator/VERSION | 2 +- .../typescript/builds/jquery/.openapi-generator/VERSION | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 40e7103019a5..442165cb9edc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -26,6 +26,8 @@ import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; +import org.openapitools.codegen.meta.GeneratorMetadata; +import org.openapitools.codegen.meta.Stability; import org.openapitools.codegen.utils.ModelUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,6 +69,8 @@ public TypeScriptClientCodegen() { this.frameworkToHttpLibMap.put("jquery", "jquery"); + this.generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build(); + // clear import mapping (from default generator) as TS does not use it // at the moment importMapping.clear(); @@ -132,7 +136,7 @@ public TypeScriptClientCodegen() { typeMapping.put("ByteArray", "string"); typeMapping.put("UUID", "string"); typeMapping.put("Error", "Error"); - + 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")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); @@ -144,7 +148,7 @@ public TypeScriptClientCodegen() { frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); - + cliOptions.add(new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC)); CliOption platformOption = new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC); for (String option: TypeScriptClientCodegen.PLATFORMS) { diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION index c3a2c7076fa8..b5d898602c2c 100644 --- a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +4.3.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION index c3a2c7076fa8..b5d898602c2c 100644 --- a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +4.3.1-SNAPSHOT \ No newline at end of file From 07dd1efb7a0aa0c1e4e972f514801966127de605 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 3 May 2020 20:58:07 +0200 Subject: [PATCH 61/85] Removed whitespace --- .../codegen/languages/TypeScriptClientCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 442165cb9edc..d91d447183af 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -141,14 +141,14 @@ public TypeScriptClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false")); - + CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { // TODO: improve description? frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); - + cliOptions.add(new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC)); CliOption platformOption = new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC); for (String option: TypeScriptClientCodegen.PLATFORMS) { From 934f226098352a4ac69d337d3157b74cd7ecb2d0 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 4 May 2020 23:58:38 +0200 Subject: [PATCH 62/85] [TS-Refactor] Top-level exports for fetch & jquery (#6138) * Added top-level exports * Updated generator README * Updated typescript generator docs --- docs/generators.md | 2 +- docs/generators/typescript.md | 238 +++++++++++++++++- .../typescript/generators/fetch-api.mustache | 26 +- .../typescript/generators/jquery.mustache | 26 +- .../typescript/builds/default/index.ts | 26 +- .../typescript/builds/jquery/index.ts | 26 +- .../tests/default/test/api/PetApi.test.ts | 16 +- .../tests/default/test/auth/auth.test.ts | 16 +- .../test/http/isomorphic-fetch.test.ts | 16 +- .../test/models/ObjectSerializer.test.ts | 22 +- .../tests/jquery/test/api/PetApi.test.ts | 18 +- .../tests/jquery/test/http/jquery.test.ts | 16 +- 12 files changed, 313 insertions(+), 135 deletions(-) diff --git a/docs/generators.md b/docs/generators.md index 04de34b9155c..9c1843213491 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -62,7 +62,7 @@ The following generators are available: * [swift3-deprecated (deprecated)](generators/swift3-deprecated.md) * [swift4](generators/swift4.md) * [swift5 (beta)](generators/swift5.md) -* [typescript](generators/typescript.md) +* [typescript (experimental)](generators/typescript.md) * [typescript-angular](generators/typescript-angular.md) * [typescript-angularjs](generators/typescript-angularjs.md) * [typescript-aurelia](generators/typescript-aurelia.md) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index c1599ef50218..68028c6230a1 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -5,13 +5,239 @@ sidebar_label: typescript | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | -|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| -|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| -|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| +|fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| +|framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| +|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. + +When this flag is set to false: + +- The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document. +- Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. +When this flag is set to true: + +- The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. +Note to developers supporting a language generator in OpenAPITools: to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.| |true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| +|platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.| |null| +|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| +|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| -|fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| |useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false| -|platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.| |null| -|framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| + +## IMPORT MAPPING + +| Type/Alias | Imports | +| ---------- | ------- | + + +## INSTANTIATION TYPES + +| Type/Alias | Instantiated By | +| ---------- | --------------- | +|array|Array| + + +## LANGUAGE PRIMITIVES + +
    +
  • Array
  • +
  • Boolean
  • +
  • Date
  • +
  • Double
  • +
  • Error
  • +
  • File
  • +
  • Float
  • +
  • Integer
  • +
  • Long
  • +
  • Map
  • +
  • Object
  • +
  • String
  • +
  • any
  • +
  • boolean
  • +
  • number
  • +
  • string
  • +
+ +## 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
  • +
  • formParams
  • +
  • function
  • +
  • goto
  • +
  • headerParams
  • +
  • if
  • +
  • implements
  • +
  • import
  • +
  • in
  • +
  • instanceof
  • +
  • int
  • +
  • interface
  • +
  • let
  • +
  • long
  • +
  • native
  • +
  • new
  • +
  • null
  • +
  • package
  • +
  • private
  • +
  • protected
  • +
  • public
  • +
  • queryParameters
  • +
  • requestOptions
  • +
  • return
  • +
  • short
  • +
  • static
  • +
  • super
  • +
  • switch
  • +
  • synchronized
  • +
  • this
  • +
  • throw
  • +
  • transient
  • +
  • true
  • +
  • try
  • +
  • typeof
  • +
  • useFormData
  • +
  • var
  • +
  • varLocalDeferred
  • +
  • varLocalPath
  • +
  • void
  • +
  • volatile
  • +
  • while
  • +
  • with
  • +
  • yield
  • +
+ +## FEATURE SET + + +### Client Modification Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasePath|✗|ToolingExtension +|Authorizations|✗|ToolingExtension +|UserAgent|✗|ToolingExtension + +### Data Type Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Custom|✗|OAS2,OAS3 +|Int32|✓|OAS2,OAS3 +|Int64|✓|OAS2,OAS3 +|Float|✓|OAS2,OAS3 +|Double|✓|OAS2,OAS3 +|Decimal|✓|ToolingExtension +|String|✓|OAS2,OAS3 +|Byte|✓|OAS2,OAS3 +|Binary|✓|OAS2,OAS3 +|Boolean|✓|OAS2,OAS3 +|Date|✓|OAS2,OAS3 +|DateTime|✓|OAS2,OAS3 +|Password|✓|OAS2,OAS3 +|File|✓|OAS2 +|Array|✓|OAS2,OAS3 +|Maps|✓|ToolingExtension +|CollectionFormat|✓|OAS2 +|CollectionFormatMulti|✓|OAS2 +|Enum|✓|OAS2,OAS3 +|ArrayOfEnum|✓|ToolingExtension +|ArrayOfModel|✓|ToolingExtension +|ArrayOfCollectionOfPrimitives|✓|ToolingExtension +|ArrayOfCollectionOfModel|✓|ToolingExtension +|ArrayOfCollectionOfEnum|✓|ToolingExtension +|MapOfEnum|✓|ToolingExtension +|MapOfModel|✓|ToolingExtension +|MapOfCollectionOfPrimitives|✓|ToolingExtension +|MapOfCollectionOfModel|✓|ToolingExtension +|MapOfCollectionOfEnum|✓|ToolingExtension + +### Documentation Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Readme|✗|ToolingExtension +|Model|✓|ToolingExtension +|Api|✓|ToolingExtension + +### Global Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Host|✓|OAS2,OAS3 +|BasePath|✓|OAS2,OAS3 +|Info|✓|OAS2,OAS3 +|Schemes|✗|OAS2,OAS3 +|PartialSchemes|✓|OAS2,OAS3 +|Consumes|✓|OAS2 +|Produces|✓|OAS2 +|ExternalDocumentation|✓|OAS2,OAS3 +|Examples|✓|OAS2,OAS3 +|XMLStructureDefinitions|✗|OAS2,OAS3 +|MultiServer|✗|OAS3 +|ParameterizedServer|✗|OAS3 +|ParameterStyling|✗|OAS3 +|Callbacks|✓|OAS3 +|LinkObjects|✗|OAS3 + +### Parameter Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Path|✓|OAS2,OAS3 +|Query|✓|OAS2,OAS3 +|Header|✓|OAS2,OAS3 +|Body|✓|OAS2 +|FormUnencoded|✓|OAS2 +|FormMultipart|✓|OAS2 +|Cookie|✓|OAS3 + +### Schema Support Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Simple|✓|OAS2,OAS3 +|Composite|✓|OAS2,OAS3 +|Polymorphism|✓|OAS2,OAS3 +|Union|✗|OAS3 + +### Security Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasicAuth|✓|OAS2,OAS3 +|ApiKey|✓|OAS2,OAS3 +|OpenIDConnect|✗|OAS3 +|BearerToken|✓|OAS3 +|OAuth2_Implicit|✓|OAS2,OAS3 +|OAuth2_Password|✓|OAS2,OAS3 +|OAuth2_ClientCredentials|✓|OAS2,OAS3 +|OAuth2_AuthorizationCode|✓|OAS2,OAS3 + +### Wire Format Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|JSON|✓|OAS2,OAS3 +|XML|✓|OAS2,OAS3 +|PROTOBUF|✗|ToolingExtension +|Custom|✗|OAS2,OAS3 diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache index ca1c5ff976ff..44c085d2dd07 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache @@ -1,19 +1,7 @@ -import * as http from './http/http'; -import * as auth from './auth/auth'; -import {Middleware, PromiseMiddleware} from './middleware'; -import * as models from './models/all'; -import { Configuration} from './configuration' -import * as apis from './types/PromiseAPI'; -import * as exceptions from './apis/exception'; - -export { - http, - - auth, - Middleware, - PromiseMiddleware, - models, - Configuration, - apis, - exceptions -}; \ No newline at end of file +export * from './http/http'; +export * from './auth/auth'; +export {Middleware, PromiseMiddleware} from './middleware'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './types/PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache index ca1c5ff976ff..44c085d2dd07 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache @@ -1,19 +1,7 @@ -import * as http from './http/http'; -import * as auth from './auth/auth'; -import {Middleware, PromiseMiddleware} from './middleware'; -import * as models from './models/all'; -import { Configuration} from './configuration' -import * as apis from './types/PromiseAPI'; -import * as exceptions from './apis/exception'; - -export { - http, - - auth, - Middleware, - PromiseMiddleware, - models, - Configuration, - apis, - exceptions -}; \ No newline at end of file +export * from './http/http'; +export * from './auth/auth'; +export {Middleware, PromiseMiddleware} from './middleware'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './types/PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index ca1c5ff976ff..44c085d2dd07 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,19 +1,7 @@ -import * as http from './http/http'; -import * as auth from './auth/auth'; -import {Middleware, PromiseMiddleware} from './middleware'; -import * as models from './models/all'; -import { Configuration} from './configuration' -import * as apis from './types/PromiseAPI'; -import * as exceptions from './apis/exception'; - -export { - http, - - auth, - Middleware, - PromiseMiddleware, - models, - Configuration, - apis, - exceptions -}; \ No newline at end of file +export * from './http/http'; +export * from './auth/auth'; +export {Middleware, PromiseMiddleware} from './middleware'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './types/PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/client/petstore/typescript/builds/jquery/index.ts index ca1c5ff976ff..44c085d2dd07 100644 --- a/samples/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/client/petstore/typescript/builds/jquery/index.ts @@ -1,19 +1,7 @@ -import * as http from './http/http'; -import * as auth from './auth/auth'; -import {Middleware, PromiseMiddleware} from './middleware'; -import * as models from './models/all'; -import { Configuration} from './configuration' -import * as apis from './types/PromiseAPI'; -import * as exceptions from './apis/exception'; - -export { - http, - - auth, - Middleware, - PromiseMiddleware, - models, - Configuration, - apis, - exceptions -}; \ No newline at end of file +export * from './http/http'; +export * from './auth/auth'; +export {Middleware, PromiseMiddleware} from './middleware'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './types/PromiseAPI'; +export * from './apis/exception'; \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 813e5321eaa1..fe9df6c67700 100644 --- a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -4,13 +4,13 @@ import { expect, assert } from "chai"; import * as fs from 'fs'; const configuration = new petstore.Configuration() -const petApi = new petstore.apis.PromisePetApi(configuration) +const petApi = new petstore.PromisePetApi(configuration) -const tag = new petstore.models.Tag(); +const tag = new petstore.Tag(); tag.name = "tag1" tag.id = Math.floor(Math.random() * 100000) -const pet = new petstore.models.Pet() +const pet = new petstore.Pet() pet.id = Math.floor(Math.random() * 100000) pet.name = "PetName" pet.photoUrls = [] @@ -22,7 +22,7 @@ describe("PetApi", () =>{ it("addPet", (done) => { petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((createdPet: petstore.models.Pet) => { + }).then((createdPet: petstore.Pet) => { expect(createdPet).to.deep.equal(pet); done() }).catch((err) => { @@ -35,7 +35,7 @@ describe("PetApi", () =>{ return petApi.deletePet(pet.id) }).then(() => { return petApi.getPetById(pet.id) - }).then((pet: petstore.models.Pet) => { + }).then((pet: petstore.Pet) => { done("Pet with id " + pet.id + " was not deleted!"); }).catch((err: any) => { if (err.code && err.code == 404) { @@ -49,7 +49,7 @@ describe("PetApi", () =>{ it("findPetsByStatus", (done) => { petApi.addPet(pet).then(() => { return petApi.findPetsByStatus(["available"]) - }).then((pets: petstore.models.Pet[]) => { + }).then((pets: petstore.Pet[]) => { expect(pets.length).to.be.at.least(1); done(); }).catch((err) => { @@ -72,7 +72,7 @@ describe("PetApi", () =>{ it("getPetById", (done) => { petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((returnedPet: petstore.models.Pet) => { + }).then((returnedPet: petstore.Pet) => { expect(returnedPet).to.deep.equal(pet); done(); }).catch((err) => { @@ -93,7 +93,7 @@ describe("PetApi", () =>{ }); }).then(() => { return petApi.getPetById(pet.id); - }).then((returnedPet: petstore.models.Pet) => { + }).then((returnedPet: petstore.Pet) => { expect(returnedPet.id).to.equal(pet.id) expect(returnedPet.name).to.equal(updatedName); done(); diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts index 5993b7404397..0a7dafc96966 100644 --- a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -6,8 +6,8 @@ import { expect} from "chai"; describe("Security Authentication", () => { describe("No Authentication", () => { it("No Authentication", () => { - let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); - let noAuth = new petstore.auth.NoAuthentication(); + let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); + let noAuth = new petstore.NoAuthentication(); noAuth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); @@ -19,8 +19,8 @@ describe("Security Authentication", () => { describe("API Key Authentication", () => { // TODO: make all params const variables it("Header API Key", () => { - let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); - let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); + let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); + let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); @@ -30,8 +30,8 @@ describe("Security Authentication", () => { }); it("Query API Key", () => { - let ctx = new petstore.http.RequestContext("http://google.com?a=b", petstore.http.HttpMethod.GET); - let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); + let ctx = new petstore.RequestContext("http://google.com?a=b", petstore.HttpMethod.GET); + let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.contain("paramName=apiKey"); @@ -40,8 +40,8 @@ describe("Security Authentication", () => { }); it("Cookie API Key", () => { - let ctx = new petstore.http.RequestContext("http://google.com", petstore.http.HttpMethod.GET); - let auth = new petstore.auth.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); + let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); + let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); auth.applySecurityAuthentication(ctx); expect(ctx.getUrl()).to.equal("http://google.com"); diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index 1cbc0f11b67c..974ebd2d1348 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -3,8 +3,8 @@ import * as petstore from "ts-petstore-client"; import { expect} from "chai"; import * as FormData from "form-data"; -let libs: { [key: string]: petstore.http.HttpLibrary } = { - "isomorphic-fetch": new petstore.http.IsomorphicFetchHttpLibrary() +let libs: { [key: string]: petstore.HttpLibrary } = { + "isomorphic-fetch": new petstore.IsomorphicFetchHttpLibrary() } @@ -13,10 +13,10 @@ for (let libName in libs) { describe("Isomorphic Fetch", () => { it("GET-Request", (done) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); + let requestContext = new petstore.RequestContext("http://httpbin.org/get", petstore.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).toPromise().then((resp: petstore.http.ResponseContext) => { + lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["headers"]).to.exist; @@ -31,7 +31,7 @@ for (let libName in libs) { }) it("POST-Request", (done) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); + let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); requestContext.addCookie("test-cookie", "cookie-value"); let formData: FormData = new FormData() @@ -40,7 +40,7 @@ for (let libName in libs) { requestContext.setBody(formData); lib.send(requestContext).toPromise().then( - (resp: petstore.http.ResponseContext) => { + (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["headers"]).to.exist; @@ -56,11 +56,11 @@ for (let libName in libs) { }); it("Cookies-Request", (done) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/cookies", petstore.http.HttpMethod.GET); + let requestContext = new petstore.RequestContext("http://httpbin.org/cookies", petstore.HttpMethod.GET); requestContext.addCookie("test-cookie", "cookie-value"); lib.send(requestContext).toPromise().then( - (resp: petstore.http.ResponseContext) => { + (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); let body = JSON.parse(resp.body); expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index e111dfe49e6b..babc4681fb4d 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -47,7 +47,7 @@ describe("ObjectSerializer", () => { }) it("Class", () => { - const input = new petstore.models.Category() + const input = new petstore.Category() input.id = 4 input.name = "Test" expect(ObjectSerializer.serialize(input, "Category", "")).to.deep.equal({ "id": input.id, "name": input.name}) @@ -62,7 +62,7 @@ describe("ObjectSerializer", () => { const tags = [] const tagResult = [] for (let i = 0; i < 2; i++) { - const tag = new petstore.models.Tag() + const tag = new petstore.Tag() tag.id = i tag.name = "Tag" + i tags.push(tag) @@ -72,10 +72,10 @@ describe("ObjectSerializer", () => { }) } - const category = new petstore.models.Category() + const category = new petstore.Category() category.id = 4 category.name = "TestCat" - const pet = new petstore.models.Pet() + const pet = new petstore.Pet() pet.id = 145 pet.category = category pet.name = "PetName" @@ -99,7 +99,7 @@ describe("ObjectSerializer", () => { const categories = [] const result = [] for (let i = 0; i < 2; i++) { - const category = new petstore.models.Category() + const category = new petstore.Category() category.id = i category.name = "Cat" + i categories.push(category) @@ -151,7 +151,7 @@ describe("ObjectSerializer", () => { }) it("Class", () => { - const input = new petstore.models.Category() + const input = new petstore.Category() input.id = 4 input.name = "Test" const deserialized = ObjectSerializer.deserialize({ "id": 4, "name": "Test"}, "Category") @@ -169,7 +169,7 @@ describe("ObjectSerializer", () => { const tags = [] const tagResult = [] for (let i = 0; i < 2; i++) { - const tag = new petstore.models.Tag() + const tag = new petstore.Tag() tag.id = i tag.name = "Tag" + i tags.push(tag) @@ -179,10 +179,10 @@ describe("ObjectSerializer", () => { }) } - const category = new petstore.models.Category() + const category = new petstore.Category() category.id = 4 category.name = "TestCat" - const pet = new petstore.models.Pet() + const pet = new petstore.Pet() pet.id = 145 pet.category = category pet.name = "PetName" @@ -200,7 +200,7 @@ describe("ObjectSerializer", () => { "photoUrls": [ "url", "other url"], "status": "available", "tags": tagResult - }, "Pet", "") as petstore.models.Pet + }, "Pet", "") as petstore.Pet expect(deserialized.constructor.name).to.equal("Pet") expect(deserialized.category.constructor.name).to.equal("Category") @@ -214,7 +214,7 @@ describe("ObjectSerializer", () => { const categories = [] const result = [] for (let i = 0; i < 2; i++) { - const category = new petstore.models.Category() + const category = new petstore.Category() category.id = i category.name = "Cat" + i categories.push(category) diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts index 89cf2b8275de..17b0b6f4d887 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts @@ -3,13 +3,13 @@ declare var QUnit: any; import * as petstore from 'ts-petstore-client' const configuration = new petstore.Configuration() -const petApi = new petstore.apis.PromisePetApi(configuration) +const petApi = new petstore.PromisePetApi(configuration) -const tag = new petstore.models.Tag(); +const tag = new petstore.Tag(); tag.name = "tag1" tag.id = Math.floor(Math.random() * 100000) -const pet = new petstore.models.Pet() +const pet = new petstore.Pet() pet.id = Math.floor(Math.random() * 100000) pet.name = "PetName" pet.photoUrls = [] @@ -22,7 +22,7 @@ QUnit.module("PetApi") QUnit.test("addPet", (assert: any) => { return petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((createdPet: petstore.models.Pet) => { + }).then((createdPet: petstore.Pet) => { assert.deepEqual(createdPet, pet); }) }) @@ -32,7 +32,7 @@ QUnit.test("deletePet", (assert: any) => { return petApi.deletePet(pet.id) }).then(() => { return petApi.getPetById(pet.id) - }).then((pet: petstore.models.Pet) => { + }).then((pet: petstore.Pet) => { throw new Error("Pet with id " + pet.id + " was not deleted!"); }).catch((err: any) => { // pet does not exist @@ -48,7 +48,7 @@ QUnit.test("deletePet", (assert: any) => { QUnit.test("findPetsByStatus", (assert: any) => { return petApi.addPet(pet).then(() => { return petApi.findPetsByStatus(["available"]) - }).then((pets: petstore.models.Pet[]) => { + }).then((pets: petstore.Pet[]) => { assert.ok(pets.length >= 1, "Found at least one pet."); }) }) @@ -68,7 +68,7 @@ QUnit.test("findPetsByStatus", (assert: any) => { QUnit.test("getPetById", (assert: any) => { return petApi.addPet(pet).then(() => { return petApi.getPetById(pet.id) - }).then((returnedPet: petstore.models.Pet) => { + }).then((returnedPet: petstore.Pet) => { assert.deepEqual(returnedPet, pet); }) }) @@ -80,13 +80,13 @@ QUnit.test("updatePet", (assert: any) => { pet.name = updatedName return petApi.updatePet(pet).then(() => { pet.name = oldName; - }).catch((err) => { + }).catch((err: any) => { pet.name = oldName throw err; }); }).then(() => { return petApi.getPetById(pet.id); - }).then((returnedPet: petstore.models.Pet) => { + }).then((returnedPet: petstore.Pet) => { assert.equal(returnedPet.id, pet.id) assert.equal(returnedPet.name, updatedName); }) diff --git a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts index 1290d544cf0f..c8715e14a275 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts +++ b/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts @@ -2,8 +2,8 @@ declare var QUnit: any; import * as petstore from "ts-petstore-client"; -let libs: { [key: string]: petstore.http.HttpLibrary } = { - "jquery": new petstore.http.JQueryHttpLibrary() +let libs: { [key: string]: petstore.HttpLibrary } = { + "jquery": new petstore.JQueryHttpLibrary() } @@ -12,10 +12,10 @@ for (let libName in libs) { QUnit.module(libName); QUnit.test("GET-Request", (assert: any) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/get", petstore.http.HttpMethod.GET); + let requestContext = new petstore.RequestContext("http://httpbin.org/get", petstore.HttpMethod.GET); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); return new Promise((resolve, reject) => { - lib.send(requestContext).toPromise().then((resp: petstore.http.ResponseContext) => { + lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); let body = JSON.parse(resp.body); assert.ok(body["headers"]); @@ -31,7 +31,7 @@ for (let libName in libs) { }) QUnit.test("POST-Request", (assert: any) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); + let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST); requestContext.setHeaderParam("X-Test-Token", "Test-Token"); let formData: FormData = new FormData() formData.append("test", "test2"); @@ -42,7 +42,7 @@ for (let libName in libs) { requestContext.setBody(formData); return new Promise((resolve, reject) => { lib.send(requestContext).toPromise().then( - (resp: petstore.http.ResponseContext) => { + (resp: petstore.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); let body = JSON.parse(resp.body); assert.ok(body["headers"]); @@ -60,12 +60,12 @@ for (let libName in libs) { }); QUnit.test("Cookie-Test", (assert: any) => { - let requestContext = new petstore.http.RequestContext("http://httpbin.org/post", petstore.http.HttpMethod.POST); + let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST); requestContext.addCookie("test", "test2"); return new Promise((resolve, reject) => { try { lib.send(requestContext).toPromise().then( - (resp: petstore.http.ResponseContext) => { + (resp: petstore.ResponseContext) => { assert.ok(false, "Expected this request to fail!") reject("Successful request with Cookie Header!") }, From 391a191ecf46a1159cc37d4a55efa92f01ffaebf Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Tue, 5 May 2020 22:53:07 +0200 Subject: [PATCH 63/85] Allow browsers File type for files (#5521) * Allow passing file parameters as File objects * Add test for jquery upload * Use HttpFile object for node platform * Regenerate samples This is by far the most common use case. A `File` object already contains the name attribute. This commit allows that information to be used directly. When sending a `Blob`, in most browsers the `File` constructor can be used to assign a file name. In all other browsers the alternative is ```typescript Object.assign(data, { name: "foobar.txt" }); ``` That is why we explicitely pass the name as third parameter to `FormData.append`. This `Object.assign` method also works for `Buffer` objects in node. If one really does not want to touch the data object in the browser it is possible to define another reference to the data with ```typescript new Blob([data], { type: data.type }) ``` or in node via ```typescript Buffer.from(data) ``` --- .../resources/typescript/api/api.mustache | 9 +- .../resources/typescript/http/http.mustache | 15 +- .../typescript/builds/default/http/http.ts | 8 +- .../typescript/builds/jquery/apis/PetApi.ts | 2 +- .../typescript/builds/jquery/http/http.ts | 5 +- .../tests/default/package-lock.json | 63 ++++-- .../typescript/tests/jquery/package-lock.json | 183 ++++++++++++++---- .../typescript/tests/jquery/package.json | 1 + .../tests/jquery/test/api/PetApi.test.ts | 29 +-- .../typescript/tests/jquery/webpack.config.js | 4 + 10 files changed, 228 insertions(+), 91 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 4ac32d6839d6..2b934d8fd442 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -92,8 +92,15 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { localVarFormParams.append('{{baseName}}', {{paramName}} as any); {{/isFile}} {{#isFile}} + {{#platforms}} + {{#node}} localVarFormParams.append('{{baseName}}', {{paramName}}.data, {{paramName}}.name); - {{/isFile}} + {{/node}} + {{^node}} + localVarFormParams.append('{{baseName}}', {{paramName}}, {{paramName}}.name); + {{/node}} + {{/platforms}} + {{/isFile}} } {{/isListContainer}} {{/formParams}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 9effd7704711..42084d9235d5 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -36,10 +36,17 @@ export enum HttpMethod { /** * Represents a http file which will be uploaded to a server. */ -export interface HttpFile { - data: {{{fileContentDataType}}}; - name: string; -} +{{#platforms}} +{{#node}} +export type HttpFile = { + data: {{{fileContentDataType}}}, + name: string +}; +{{/node}} +{{^node}} +export type HttpFile = {{{fileContentDataType}}} & { readonly name: string }; +{{/node}} +{{/platforms}} export class HttpException extends Error { diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 415a86c7d19e..78b3667e747d 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -25,10 +25,10 @@ export enum HttpMethod { /** * Represents a http file which will be uploaded to a server. */ -export interface HttpFile { - data: Buffer; - name: string; -} +export type HttpFile = { + data: Buffer, + name: string +}; export class HttpException extends Error { diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts index 31693b0eb4c3..4882a9d216da 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -364,7 +364,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { } if (file !== undefined) { // TODO: replace .append with .set - localVarFormParams.append('file', file.data, file.name); + localVarFormParams.append('file', file, file.name); } requestContext.setBody(localVarFormParams); diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 14c71de90df2..1071360efbc4 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -23,10 +23,7 @@ export enum HttpMethod { /** * Represents a http file which will be uploaded to a server. */ -export interface HttpFile { - data: Blob; - name: string; -} +export type HttpFile = Blob & { readonly name: string }; export class HttpException extends Error { diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index d4543da26987..23c63616b5da 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -1226,45 +1226,54 @@ "dependencies": { "@types/isomorphic-fetch": { "version": "0.0.34", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" }, "@types/node": { "version": "12.12.7", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, "asynckit": { "version": "0.4.0", - "bundled": true + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "btoa": { "version": "1.2.1", - "bundled": true + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { "version": "1.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "encoding": { "version": "0.1.12", - "bundled": true, + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", "requires": { "iconv-lite": "~0.4.13" } }, "es6-promise": { "version": "4.2.5", - "bundled": true + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" }, "form-data": { "version": "2.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -1273,18 +1282,21 @@ }, "iconv-lite": { "version": "0.4.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, "is-stream": { "version": "1.1.0", - "bundled": true + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" }, "isomorphic-fetch": { "version": "2.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "requires": { "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" @@ -1292,18 +1304,21 @@ }, "mime-db": { "version": "1.40.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { "mime-db": "1.40.0" } }, "node-fetch": { "version": "1.7.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", "requires": { "encoding": "^0.1.11", "is-stream": "^1.0.1" @@ -1311,23 +1326,28 @@ }, "querystringify": { "version": "2.1.0", - "bundled": true + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", + "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==" }, "requires-port": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "safer-buffer": { "version": "2.1.2", - "bundled": true + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "typescript": { "version": "2.9.2", - "bundled": true + "resolved": false, + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" }, "url-parse": { "version": "1.4.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", + "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", "requires": { "querystringify": "^2.0.0", "requires-port": "^1.0.0" @@ -1335,7 +1355,8 @@ }, "whatwg-fetch": { "version": "3.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } }, diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index f1ff014ed63d..75916fc87813 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -1888,7 +1888,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1906,11 +1907,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1923,15 +1926,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2034,7 +2040,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2044,6 +2051,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2056,17 +2064,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2083,6 +2094,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2155,7 +2167,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2165,6 +2178,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2240,7 +2254,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2270,6 +2285,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2287,6 +2303,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2325,11 +2342,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -3761,6 +3780,52 @@ "safe-buffer": "^5.1.0" } }, + "raw-loader": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.0.tgz", + "integrity": "sha512-iINUOYvl1cGEmfoaLjnZXt4bKfT2LJnZZib5N/LLyAphC+Dd11vNP9CNVb38j+SAJpFI1uo8j9frmih53ASy7Q==", + "dev": true, + "requires": { + "loader-utils": "^1.2.3", + "schema-utils": "^2.5.0" + }, + "dependencies": { + "ajv": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz", + "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", + "dev": true + }, + "schema-utils": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.6.4.tgz", + "integrity": "sha512-VNjcaUxVnEeun6B2fiiUDjXXBtD4ZSH7pdbfIu1pOFwgptDPLMo/z9jr4sUfsjFVPqDCEin/F7IYlq7/E6yDbQ==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1" + } + } + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -4687,25 +4752,29 @@ "dependencies": { "@types/form-data": { "version": "2.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", "requires": { "@types/node": "*" } }, "@types/jquery": { "version": "3.3.29", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", + "integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==", "requires": { "@types/sizzle": "*" } }, "@types/node": { "version": "12.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" }, "@types/rx": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*", @@ -4723,18 +4792,21 @@ }, "@types/rx-core": { "version": "4.0.3", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" }, "@types/rx-core-binding": { "version": "4.0.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", "requires": { "@types/rx-core": "*" } }, "@types/rx-lite": { "version": "4.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*" @@ -4742,97 +4814,113 @@ }, "@types/rx-lite-aggregates": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-async": { "version": "4.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-backpressure": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-coincidence": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-experimental": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-joinpatterns": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-testing": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", "requires": { "@types/rx-lite-virtualtime": "*" } }, "@types/rx-lite-time": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-virtualtime": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", "requires": { "@types/rx-lite": "*" } }, "@types/sizzle": { "version": "2.3.2", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", + "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" }, "asynckit": { "version": "0.4.0", - "bundled": true + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "btoa": { "version": "1.2.1", - "bundled": true + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { "version": "1.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "es6-promise": { "version": "4.2.6", - "bundled": true + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, "form-data": { "version": "2.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -4841,45 +4929,54 @@ }, "jquery": { "version": "3.4.1", - "bundled": true + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", + "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" }, "mime-db": { "version": "1.40.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { "mime-db": "1.40.0" } }, "querystringify": { "version": "2.1.1", - "bundled": true + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" }, "requires-port": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "rxjs": { "version": "6.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", "requires": { "tslib": "^1.9.0" } }, "tslib": { "version": "1.9.3", - "bundled": true + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, "typescript": { "version": "2.9.2", - "bundled": true + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" }, "url-parse": { "version": "1.4.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/client/petstore/typescript/tests/jquery/package.json index f83edaf156d3..37ac165cdd01 100644 --- a/samples/client/petstore/typescript/tests/jquery/package.json +++ b/samples/client/petstore/typescript/tests/jquery/package.json @@ -21,6 +21,7 @@ }, "devDependencies": { "@types/node": "^8.10.48", + "raw-loader": "^4.0.0", "ts-loader": "^4.3.1", "typescript": "^2.4.1" }, diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts index 17b0b6f4d887..b01b9500b5d1 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts +++ b/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts @@ -1,6 +1,9 @@ declare var QUnit: any; -import * as petstore from 'ts-petstore-client' +import * as petstore from 'ts-petstore-client'; + +// @ts-ignore +import petImage from "./pet.png"; const configuration = new petstore.Configuration() const petApi = new petstore.PromisePetApi(configuration) @@ -38,7 +41,7 @@ QUnit.test("deletePet", (assert: any) => { // pet does not exist if (err.code && err.code == 404) { assert.ok(true, "404'd on getPet after deletion - all good.") - return; + return; } else { throw err; } @@ -108,14 +111,14 @@ QUnit.test("updatePet", (assert: any) => { }) })*/ -/** not easily possible? -QUnit.test("uploadFile", (done) => { - const image = fs.readFileSync(__dirname + "/pet.png") - petApi.uploadFile(pet.id, "Metadata", { name: "pet.png", data: image}).then((response: any) => { - expect(response.code).to.be.gte(200).and.lt(300); - expect(response.message).to.contain("pet.png"); - done(); - }).catch((err) => { - done(err); - }) -})*/ +QUnit.test("uploadFile", (assert: any) => { + const petImageFile: File = new File([petImage], "pet.png") + return petApi.uploadFile(pet.id, "Metadata", petImageFile) + .then( + (response: any) => { + assert.ok(response.code >= 200); + assert.ok(response.code < 300); + assert.ok(response.message.includes("pet.png")); + } + ) +}) diff --git a/samples/client/petstore/typescript/tests/jquery/webpack.config.js b/samples/client/petstore/typescript/tests/jquery/webpack.config.js index 8a612b675bd2..bea87945ed5b 100644 --- a/samples/client/petstore/typescript/tests/jquery/webpack.config.js +++ b/samples/client/petstore/typescript/tests/jquery/webpack.config.js @@ -5,6 +5,10 @@ module.exports = { mode: "development", module: { rules: [ + { + test: /\.png$/, + use: 'raw-loader' + }, { test: /\.tsx?$/, use: 'ts-loader', From 303ec6c04b4fcd4d66e1f323fe3c07b90812c74c Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 16 May 2020 19:01:08 +0200 Subject: [PATCH 64/85] [TS-Refactor] Added options for npm version, repository, name and updated readme (#6139) * Added options for npm version, repository, name and updated readme * Removed `this` where not required * Updated typescript docs --- docs/generators/typescript.md | 4 + .../languages/TypeScriptClientCodegen.java | 87 +++++++++++++++++++ .../main/resources/typescript/README.mustache | 31 ++++++- .../resources/typescript/package.mustache | 2 +- .../typescript/builds/default/README.md | 31 ++++++- .../typescript/builds/jquery/README.md | 31 ++++++- 6 files changed, 182 insertions(+), 4 deletions(-) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 68028c6230a1..5fd3402dc6c9 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -20,8 +20,12 @@ When this flag is set to true: - The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. Note to developers supporting a language generator in OpenAPITools: to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.| |true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| +|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| +|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| +|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0| |platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.| |null| |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index d91d447183af..322d41e38d3d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; import static org.openapitools.codegen.utils.StringUtils.camelize; @@ -58,6 +59,19 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private final Map frameworkToHttpLibMap; + // NPM Options + private static final String SNAPSHOT = "snapshot"; + @SuppressWarnings("squid:S5164") + protected static final ThreadLocal SNAPSHOT_SUFFIX_FORMAT = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT)); + private static final String NPM_REPOSITORY = "npmRepository"; + private static final String NPM_NAME = "npmName"; + private static final String NPM_VERSION = "npmVersion"; + + // NPM Option Values + protected String npmRepository = null; + protected String snapshot = null; + protected String npmName = null; + protected String npmVersion = "1.0.0"; protected String modelPropertyNaming = "camelCase"; protected HashSet languageGenericTypes; @@ -137,6 +151,15 @@ public TypeScriptClientCodegen() { typeMapping.put("UUID", "string"); typeMapping.put("Error", "Error"); + + cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." + + " Required to generate a full package")); + cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion())); + cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); + cliOptions.add(CliOption.newBoolean(SNAPSHOT, + "When setting this property to true, the version will be suffixed with -SNAPSHOT." + this.SNAPSHOT_SUFFIX_FORMAT.get().toPattern(), + false)); + 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")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); @@ -198,12 +221,60 @@ public TypeScriptClientCodegen() { this.apiTemplateFiles.put("api/api.mustache", ".ts"); } + public String getNpmName() { + return npmName; + } + + public void setNpmName(String npmName) { + this.npmName = npmName; + } + + public String getNpmRepository() { + return npmRepository; + } + + public void setNpmRepository(String npmRepository) { + this.npmRepository = npmRepository; + } + public String getNpmVersion() { + return npmVersion; + } + + public void setNpmVersion(String npmVersion) { + this.npmVersion = npmVersion; + } + @Override public CodegenType getTag() { return CodegenType.CLIENT; } + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + + if (additionalProperties.containsKey(NPM_NAME)) { + + // If no npmVersion is provided in additional properties, version from API specification is used. + // If none of them is provided then fallbacks to default version + if (additionalProperties.containsKey(NPM_VERSION)) { + this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); + } else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) { + this.setNpmVersion(openAPI.getInfo().getVersion()); + } + + if (additionalProperties.containsKey(SNAPSHOT) && Boolean.parseBoolean(additionalProperties.get(SNAPSHOT).toString())) { + if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { + this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.get().format(new Date())); + } else { + this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.get().format(new Date())); + } + } + additionalProperties.put(NPM_VERSION, npmVersion); + + } + } + @Override public Map postProcessSupportingFileData(Map objs) { final Object propFramework = additionalProperties.get(FRAMEWORK_SWITCH); @@ -749,6 +820,22 @@ public void processOpts() { supportingFiles.add(new SupportingFile("rxjsStub.mustache", "", "rxjsStub.ts")); } + // NPM Settings + if (additionalProperties.containsKey(NPM_NAME)) { + setNpmName(additionalProperties.get(NPM_NAME).toString()); + } + + if (additionalProperties.containsKey(NPM_VERSION)) { + setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); + } + + if (additionalProperties.containsKey(NPM_REPOSITORY)) { + setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); + } + + + + } private String getHttpLibForFramework(String object) { diff --git a/modules/openapi-generator/src/main/resources/typescript/README.mustache b/modules/openapi-generator/src/main/resources/typescript/README.mustache index ea786ff2cf69..d1c61395920d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/README.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/README.mustache @@ -1 +1,30 @@ -readme \ No newline at end of file +## {{npmName}}@{{npmVersion}} + +This generator creates TypeScript/JavaScript client that utilizes {{framework}}. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install {{npmName}}@{{npmVersion}} --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index ec0e6303f984..67d117572084 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -1,6 +1,6 @@ { "name": "{{npmName}}", - "version": "1.0.0", + "version": "{{npmVersion}}", "description": "OpenAPI client for {{npmName}}", "author": "OpenAPI-Generator Contributors", "keywords": [ diff --git a/samples/client/petstore/typescript/builds/default/README.md b/samples/client/petstore/typescript/builds/default/README.md index ea786ff2cf69..80b1ac5cc98b 100644 --- a/samples/client/petstore/typescript/builds/default/README.md +++ b/samples/client/petstore/typescript/builds/default/README.md @@ -1 +1,30 @@ -readme \ No newline at end of file +## ts-petstore-client@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes fetch-api. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install ts-petstore-client@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/samples/client/petstore/typescript/builds/jquery/README.md b/samples/client/petstore/typescript/builds/jquery/README.md index ea786ff2cf69..9cccd82f8338 100644 --- a/samples/client/petstore/typescript/builds/jquery/README.md +++ b/samples/client/petstore/typescript/builds/jquery/README.md @@ -1 +1,30 @@ -readme \ No newline at end of file +## ts-petstore-client@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes jquery. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install ts-petstore-client@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save From 659369c3ea959aca66d26d4c7613ce6eeae094c1 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Thu, 21 May 2020 15:34:14 +0200 Subject: [PATCH 65/85] Typescript refactor fixes (#6027) Fixes a handful of issues identified in https://github.com/OpenAPITools/openapi-generator/issues/802#issuecomment-617262139 List of changes * Clean: Remove redundant cliOption definition * Remove redundant directory structure in templates If we need to have different index.ts files for the different frameworks, we can mostly do that in the one mustache file. In the cases where that is not possible, we can still add a new override file later. * Use File.separator consistently * Only export selected api type * Simplify promise polyfill import The behaviour should be the same, according to the es6-promise docs. Previously tsc would report the error: > error TS2307: Cannot find module 'es6-promise'. * Import HttpFile in all models * Export server configurations * Use undefined as default body value The empty string is not interpreted as "no body" by the browser fetch api and thus leads to an exception during get requests * Improve codestyle: prefer guards to nesting * Remove verbose debug output This should not be commited, because every developer has very different requirements what debug information he needs to see. * Fix: Use cleaned model names for imports * Fix: do not call toString on undefined * Fix typo in doc comment * Introduce RequestBody type and remove method check --- docs/generators/typescript.md | 2 +- .../codegen/DefaultGenerator.java | 60 ++++----- .../languages/TypeScriptClientCodegen.java | 41 +++--- .../resources/typescript/api/api.mustache | 20 +-- .../typescript/generators/fetch-api.mustache | 7 - .../typescript/generators/jquery.mustache | 7 - .../resources/typescript/http/http.mustache | 44 +++---- .../typescript/http/isomorphic-fetch.mustache | 3 +- .../resources/typescript/http/jquery.mustache | 2 +- .../main/resources/typescript/index.mustache | 15 +++ .../resources/typescript/model/model.mustache | 1 + .../typescript/model/models_all.mustache | 2 +- .../types/ObservableAPI.mustache | 2 +- .../types/PromiseAPI.mustache | 2 +- .../typescript/builds/default/apis/PetApi.ts | 118 ++++++++--------- .../builds/default/apis/StoreApi.ts | 60 ++++----- .../typescript/builds/default/apis/UserApi.ts | 122 +++++++++--------- .../typescript/builds/default/http/http.ts | 44 +++---- .../builds/default/http/isomorphic-fetch.ts | 3 +- .../typescript/builds/default/index.ts | 8 +- .../builds/default/models/ApiResponse.ts | 1 + .../builds/default/models/Category.ts | 1 + .../typescript/builds/default/models/Order.ts | 1 + .../typescript/builds/default/models/Pet.ts | 1 + .../typescript/builds/default/models/Tag.ts | 1 + .../typescript/builds/default/models/User.ts | 1 + .../typescript/builds/jquery/apis/PetApi.ts | 118 ++++++++--------- .../typescript/builds/jquery/apis/StoreApi.ts | 60 ++++----- .../typescript/builds/jquery/apis/UserApi.ts | 122 +++++++++--------- .../typescript/builds/jquery/http/http.ts | 44 +++---- .../typescript/builds/jquery/http/jquery.ts | 2 +- .../typescript/builds/jquery/index.ts | 8 +- .../builds/jquery/models/ApiResponse.ts | 1 + .../builds/jquery/models/Category.ts | 1 + .../typescript/builds/jquery/models/Order.ts | 1 + .../typescript/builds/jquery/models/Pet.ts | 1 + .../typescript/builds/jquery/models/Tag.ts | 1 + .../typescript/builds/jquery/models/User.ts | 1 + .../tests/default/test/auth/auth.test.ts | 8 +- 39 files changed, 468 insertions(+), 469 deletions(-) delete mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/index.mustache rename modules/openapi-generator/src/main/resources/typescript/{generators => }/types/ObservableAPI.mustache (97%) rename modules/openapi-generator/src/main/resources/typescript/{generators => }/types/PromiseAPI.mustache (95%) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 5fd3402dc6c9..b711cadad68c 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -23,7 +23,7 @@ Note to developers supporting a language generator in OpenAPITools: to fully sup |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| |npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0| -|platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.| |null| +|platform|Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise.|
**browser**
browser
**node**
node
|browser| |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 1681434c4424..a9033d9bc1dd 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -783,40 +783,40 @@ private void generateSupportingFiles(List files, Map bundl continue; } - if (ignoreProcessor.allowsFile(new File(outputFilename))) { - // support.templateFile is the unmodified/original supporting file name (e.g. build.sh.mustache) - // templatingEngine.templateExists dispatches resolution to this, performing template-engine specific inspect of support file extensions. - if (templatingEngine.templateExists(this, support.templateFile)) { - String templateContent = templatingEngine.compileTemplate(this, bundle, support.templateFile); - writeToFile(outputFilename, templateContent); - File written = new File(outputFilename); - files.add(written); - if (config.isEnablePostProcessFile()) { - config.postProcessFile(written, "supporting-mustache"); - } - } else { - InputStream in = null; - - try { - in = new FileInputStream(templateFile); - } catch (Exception e) { - // continue - } - if (in == null) { - in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile)); - } - File outputFile = writeInputStreamToFile(outputFilename, in, templateFile); - files.add(outputFile); - if (config.isEnablePostProcessFile() && !dryRun) { - config.postProcessFile(outputFile, "supporting-common"); - } - } - - } else { + if (!ignoreProcessor.allowsFile(new File(outputFilename))) { if (dryRun) { dryRunStatusMap.put(outputFilename, new DryRunStatus(java.nio.file.Paths.get(outputFilename), DryRunStatus.State.Ignored)); } LOGGER.info("Skipped generation of {} due to rule in .openapi-generator-ignore", outputFilename); + continue; + } + + // support.templateFile is the unmodified/original supporting file name (e.g. build.sh.mustache) + // templatingEngine.templateExists dispatches resolution to this, performing template-engine specific inspect of support file extensions. + if (templatingEngine.templateExists(this, support.templateFile)) { + String templateContent = templatingEngine.compileTemplate(this, bundle, support.templateFile); + writeToFile(outputFilename, templateContent); + File written = new File(outputFilename); + files.add(written); + if (config.isEnablePostProcessFile()) { + config.postProcessFile(written, "supporting-mustache"); + } + } else { + InputStream in = null; + + try { + in = new FileInputStream(templateFile); + } catch (Exception e) { + // continue + } + if (in == null) { + in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile)); + } + File outputFile = writeInputStreamToFile(outputFilename, in, templateFile); + files.add(outputFile); + if (config.isEnablePostProcessFile() && !dryRun) { + config.postProcessFile(outputFile, "supporting-common"); + } } } catch (Exception e) { throw new RuntimeException("Could not generate supporting file '" + support + "'", e); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 322d41e38d3d..38a3e7502a20 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -88,7 +88,7 @@ public TypeScriptClientCodegen() { // clear import mapping (from default generator) as TS does not use it // at the moment importMapping.clear(); - outputFolder = "generated-code/typescript"; + outputFolder = "generated-code" + File.separator + "typescript"; embeddedTemplateDir = templateDir = "typescript"; supportsInheritance = true; @@ -171,8 +171,8 @@ public TypeScriptClientCodegen() { frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); + cliOptions.add(frameworkOption); - cliOptions.add(new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC)); CliOption platformOption = new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC); for (String option: TypeScriptClientCodegen.PLATFORMS) { // TODO: improve description? @@ -180,9 +180,9 @@ public TypeScriptClientCodegen() { } platformOption.defaultValue(PLATFORMS[0]); - cliOptions.add(frameworkOption); - - + cliOptions.add(platformOption); + + // TODO: gen package.json? //Documentation @@ -194,31 +194,31 @@ public TypeScriptClientCodegen() { // Util supportingFiles.add(new SupportingFile("util.mustache", "", "util.ts")); - supportingFiles.add(new SupportingFile("api/exception.mustache", "apis", "exception.ts")); + supportingFiles.add(new SupportingFile("api" + File.separator + "exception.mustache", "apis", "exception.ts")); // http supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts")); - supportingFiles.add(new SupportingFile("http/servers.mustache", "servers.ts")); + supportingFiles.add(new SupportingFile("http" + File.separator + "servers.mustache", "servers.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts")); - supportingFiles.add(new SupportingFile("model/models_all.mustache", "models", "all.ts")); + supportingFiles.add(new SupportingFile("model" + File.separator + "models_all.mustache", "models", "all.ts")); // TODO: add supporting files depending on cli parameter e.g. fetch vs angular - supportingFiles.add(new SupportingFile("generators/types/PromiseAPI.mustache", "types", "PromiseAPI.ts")); - supportingFiles.add(new SupportingFile("generators/types/ObservableAPI.mustache", "types", "ObservableAPI.ts")); + supportingFiles.add(new SupportingFile("types" + File.separator + "PromiseAPI.mustache", "types", "PromiseAPI.ts")); + supportingFiles.add(new SupportingFile("types" + File.separator + "ObservableAPI.mustache", "types", "ObservableAPI.ts")); // models // TODO: properly set model and api packages this.setModelPackage(""); - supportingFiles.add(new SupportingFile("model/ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); - modelTemplateFiles.put("model/model.mustache", ".ts"); + supportingFiles.add(new SupportingFile("model" + File.separator + "ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); + modelTemplateFiles.put("model" + File.separator + "model.mustache", ".ts"); // api this.setApiPackage(""); - supportingFiles.add(new SupportingFile("api/middleware.mustache", "", "middleware.ts")); - this.supportingFiles.add(new SupportingFile("api/baseapi.mustache", "apis", "baseapi.ts")); - this.apiTemplateFiles.put("api/api.mustache", ".ts"); + supportingFiles.add(new SupportingFile("api" + File.separator + "middleware.mustache", "", "middleware.ts")); + this.supportingFiles.add(new SupportingFile("api" + File.separator + "baseapi.mustache", "apis", "baseapi.ts")); + this.apiTemplateFiles.put("api" + File.separator + "api.mustache", ".ts"); } public String getNpmName() { @@ -297,7 +297,7 @@ public Map postProcessOperationsWithModels(Map o // Add additional filename information for model imports in the apis List> imports = (List>) operations.get("imports"); for (Map im : imports) { - im.put("filename", ((String) im.get("import")).replace('.', '/')); + im.put("filename", ((String) im.get("import")).replace(".", File.separator)); im.put("classname", getModelnameFromModelFilename(im.get("import").toString())); } @@ -316,7 +316,6 @@ private String getReturnType(List responses) { boolean firstReturnType = true; boolean atLeastOneSuccess = false; boolean addVoid = false; - System.out.println(responses); for (CodegenResponse response: responses) { // TODO: we should probably catch an exception here if (response.isSuccessCode) { @@ -338,7 +337,6 @@ private String getReturnType(List responses) { returnType.append(" | void"); } - System.out.println("Return Type: " + returnType); return returnType.toString(); } @@ -790,10 +788,7 @@ public void processOpts() { testPackage = this.testPackage + ".tests"; additionalProperties.putIfAbsent(FRAMEWORK_SWITCH, FRAMEWORKS[0]); - supportingFiles.add(new SupportingFile( - "generators" + File.separator + additionalProperties.get(FRAMEWORK_SWITCH) + ".mustache", - "index.ts" - )); + supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); String httpLibName = this.getHttpLibForFramework(additionalProperties.get(FRAMEWORK_SWITCH).toString()); supportingFiles.add(new SupportingFile( @@ -817,7 +812,7 @@ public void processOpts() { final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH); if (!useRxJS) { - supportingFiles.add(new SupportingFile("rxjsStub.mustache", "", "rxjsStub.ts")); + supportingFiles.add(new SupportingFile("rxjsStub.mustache", "rxjsStub.ts")); } // NPM Settings diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 2b934d8fd442..c74876f1242a 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -118,7 +118,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{/consumes.0}} // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("{{dataType}}" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}}.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); {{/bodyParam}} @@ -144,15 +144,15 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#operations}} export class {{classname}}ResponseProcessor { - - {{#operation}} - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to {{nicknam}} - * @throws ApiException if the response code was not in [200, 299] - */ + + {{#operation}} + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to {{nickname}} + * @throws ApiException if the response code was not in [200, 299] + */ public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { {{#responses}} if (isCodeInRange("{{code}}", response.httpStatusCode)) { diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache deleted file mode 100644 index 44c085d2dd07..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/generators/fetch-api.mustache +++ /dev/null @@ -1,7 +0,0 @@ -export * from './http/http'; -export * from './auth/auth'; -export {Middleware, PromiseMiddleware} from './middleware'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './types/PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache deleted file mode 100644 index 44c085d2dd07..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript/generators/jquery.mustache +++ /dev/null @@ -1,7 +0,0 @@ -export * from './http/http'; -export * from './auth/auth'; -export {Middleware, PromiseMiddleware} from './middleware'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './types/PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 42084d9235d5..2850e31dabb1 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -19,7 +19,7 @@ export * from './jquery'; {{/frameworks}} /** - * Represents a HTTP Method. + * Represents an HTTP method. */ export enum HttpMethod { GET = "GET", @@ -34,7 +34,7 @@ export enum HttpMethod { } /** - * Represents a http file which will be uploaded to a server. + * Represents an HTTP file which will be transferred from or to a server. */ {{#platforms}} {{#node}} @@ -56,14 +56,18 @@ export class HttpException extends Error { } /** - * Represents a HTTP request context - * + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData; + +/** + * Represents an HTTP request context */ export class RequestContext { private headers: { [key: string]: string } = {}; - private body: string | FormData = ""; - private url: URLParse; - + private body: RequestBody = undefined; + private url: URLParse; + /** * Creates the request context using a http method and request resource url * @@ -90,27 +94,19 @@ export class RequestContext { this.url = URLParse(url, true); } - /** * Sets the body of the http request either as a string or FormData - * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section - * 4.3 and this method throws an HttpException accordingly. + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 * * @param body the body of the request */ - public setBody(body: string | FormData) { - // HTTP-Spec 1.1 Section 4.3 - if (this.httpMethod === HttpMethod.GET) { - throw new HttpException("Body should not be included in GET-Requests!"); - } - - // TODO: other http methods - - // post is fine either formData or string + public setBody(body: RequestBody) { this.body = body; - } - + public getHttpMethod(): HttpMethod { return this.httpMethod; } @@ -118,9 +114,9 @@ export class RequestContext { public getHeaders(): { [key: string]: string } { return this.headers; } - - public getBody(): string | FormData { - return this.body; + + public getBody(): RequestBody { + return this.body; } public setQueryParam(name: string, value: string) { diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index ef6b2960f6f6..f25e141554e9 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,9 +1,8 @@ declare var fetch: any; import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import * as e6p from 'es6-promise' +import 'es6-promise/auto'; import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; -e6p.polyfill(); import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index dd08009ff3a0..63fc7d39185a 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -42,7 +42,7 @@ export class JQueryHttpLibrary implements HttpLibrary { throw new HttpException("Setting the \"Cookie\"-Header field is blocked by every major browser when using jquery.ajax requests. Please switch to another library like fetch to enable this option"); } - if (body.constructor.name == "FormData") { + if (body && body.constructor.name == "FormData") { requestOptions.contentType = false; } const sentRequest = $.ajax(requestOptions); diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache new file mode 100644 index 000000000000..b1e833cf960b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -0,0 +1,15 @@ +export * from './http/http'; +export * from './auth/auth'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './apis/exception'; +export * from './servers'; + +{{#useRxJS}} + export * from './types/ObservableAPI'; + export { Middleware } from './middleware'; +{{/useRxJS}} +{{^useRxJS}} + export * from './types/PromiseAPI'; + export { PromiseMiddleware as Middleware } from './middleware'; +{{/useRxJS}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index b3539527bd41..eafef58daa03 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -4,6 +4,7 @@ {{#tsImports}} import { {{classname}} } from './{{filename}}'; {{/tsImports}} +import { HttpFile } from '../http/http'; {{#description}} /** diff --git a/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache b/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache index 821581f4b37f..59c37a824222 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache @@ -1,5 +1,5 @@ {{#models}} {{#model}} -export * from './{{name}}' +export * from './{{{ classFilename }}}' {{/model}} {{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache similarity index 97% rename from modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache rename to modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache index 95052bde59bd..2ce28f0a7735 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache @@ -6,7 +6,7 @@ import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS} {{#models}} {{#model}} -import { {{name}} } from '../models/{{name}}'; +import { {{{ classname }}} } from '../models/{{{ classFilename }}}'; {{/model}} {{/models}} {{#apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache similarity index 95% rename from modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache rename to modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache index 4f6227d57e9c..dae804a53481 100644 --- a/modules/openapi-generator/src/main/resources/typescript/generators/types/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache @@ -4,7 +4,7 @@ import { Configuration} from '../configuration' {{#models}} {{#model}} -import { {{name}} } from '../models/{{name}}'; +import { {{{ classname }}} } from '../models/{{{ classFilename }}}'; {{/model}} {{/models}} {{#apiInfo}} diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 7f9e16f207a2..8744f0909be1 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -46,7 +46,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; @@ -260,7 +260,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; @@ -386,14 +386,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { export class PetApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to addPet + * @throws ApiException if the response code was not in [200, 299] + */ public addPet(response: ResponseContext): void { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); @@ -407,13 +407,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deletePet + * @throws ApiException if the response code was not in [200, 299] + */ public deletePet(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); @@ -427,13 +427,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByStatus + * @throws ApiException if the response code was not in [200, 299] + */ public findPetsByStatus(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -454,13 +454,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByTags + * @throws ApiException if the response code was not in [200, 299] + */ public findPetsByTags(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -481,13 +481,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getPetById + * @throws ApiException if the response code was not in [200, 299] + */ public getPetById(response: ResponseContext): Pet { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -511,13 +511,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePet + * @throws ApiException if the response code was not in [200, 299] + */ public updatePet(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); @@ -537,13 +537,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePetWithForm + * @throws ApiException if the response code was not in [200, 299] + */ public updatePetWithForm(response: ResponseContext): void { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); @@ -557,13 +557,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to uploadFile + * @throws ApiException if the response code was not in [200, 299] + */ public uploadFile(response: ResponseContext): ApiResponse { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 55769fdc2491..2168c95ddb90 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -150,7 +150,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -163,14 +163,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { export class StoreApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteOrder + * @throws ApiException if the response code was not in [200, 299] + */ public deleteOrder(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); @@ -187,13 +187,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getInventory + * @throws ApiException if the response code was not in [200, 299] + */ public getInventory(response: ResponseContext): { [key: string]: number; } { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -211,13 +211,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getOrderById + * @throws ApiException if the response code was not in [200, 299] + */ public getOrderById(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -241,13 +241,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to placeOrder + * @throws ApiException if the response code was not in [200, 299] + */ public placeOrder(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index b3040726a8f0..9a4c150a22fe 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -46,7 +46,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -85,7 +85,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -124,7 +124,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -317,7 +317,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -330,14 +330,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { export class UserApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUser + * @throws ApiException if the response code was not in [200, 299] + */ public createUser(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -351,13 +351,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithArrayInput + * @throws ApiException if the response code was not in [200, 299] + */ public createUsersWithArrayInput(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -371,13 +371,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithListInput + * @throws ApiException if the response code was not in [200, 299] + */ public createUsersWithListInput(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -391,13 +391,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteUser + * @throws ApiException if the response code was not in [200, 299] + */ public deleteUser(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); @@ -414,13 +414,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getUserByName + * @throws ApiException if the response code was not in [200, 299] + */ public getUserByName(response: ResponseContext): User { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -444,13 +444,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to loginUser + * @throws ApiException if the response code was not in [200, 299] + */ public loginUser(response: ResponseContext): string { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -471,13 +471,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to logoutUser + * @throws ApiException if the response code was not in [200, 299] + */ public logoutUser(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -491,13 +491,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateUser + * @throws ApiException if the response code was not in [200, 299] + */ public updateUser(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 78b3667e747d..7549c847aa3a 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -8,7 +8,7 @@ import { Observable } from '../rxjsStub'; export * from './isomorphic-fetch'; /** - * Represents a HTTP Method. + * Represents an HTTP method. */ export enum HttpMethod { GET = "GET", @@ -23,7 +23,7 @@ export enum HttpMethod { } /** - * Represents a http file which will be uploaded to a server. + * Represents an HTTP file which will be transferred from or to a server. */ export type HttpFile = { data: Buffer, @@ -38,14 +38,18 @@ export class HttpException extends Error { } /** - * Represents a HTTP request context - * + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData; + +/** + * Represents an HTTP request context */ export class RequestContext { private headers: { [key: string]: string } = {}; - private body: string | FormData = ""; - private url: URLParse; - + private body: RequestBody = undefined; + private url: URLParse; + /** * Creates the request context using a http method and request resource url * @@ -72,27 +76,19 @@ export class RequestContext { this.url = URLParse(url, true); } - /** * Sets the body of the http request either as a string or FormData - * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section - * 4.3 and this method throws an HttpException accordingly. + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 * * @param body the body of the request */ - public setBody(body: string | FormData) { - // HTTP-Spec 1.1 Section 4.3 - if (this.httpMethod === HttpMethod.GET) { - throw new HttpException("Body should not be included in GET-Requests!"); - } - - // TODO: other http methods - - // post is fine either formData or string + public setBody(body: RequestBody) { this.body = body; - } - + public getHttpMethod(): HttpMethod { return this.httpMethod; } @@ -100,9 +96,9 @@ export class RequestContext { public getHeaders(): { [key: string]: string } { return this.headers; } - - public getBody(): string | FormData { - return this.body; + + public getBody(): RequestBody { + return this.body; } public setQueryParam(name: string, value: string) { diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index 0793c34bf44f..f7e6474c2532 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -1,9 +1,8 @@ declare var fetch: any; import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import * as e6p from 'es6-promise' +import 'es6-promise/auto'; import { from, Observable } from '../rxjsStub'; -e6p.polyfill(); import 'isomorphic-fetch'; export class IsomorphicFetchHttpLibrary implements HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index 44c085d2dd07..fd12234aa0ec 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,7 +1,9 @@ export * from './http/http'; export * from './auth/auth'; -export {Middleware, PromiseMiddleware} from './middleware'; export * from './models/all'; export { Configuration} from './configuration' -export * from './types/PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file +export * from './apis/exception'; +export * from './servers'; + + export * from './types/PromiseAPI'; + export { PromiseMiddleware as Middleware } from './middleware'; diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index 1e4383431b77..300b2de4d9a9 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index 69d6879fb9bd..9b210d5d501d 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A category for a pet diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index 0ef6a1dbef14..291018b9e065 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index cf45a4341f34..77a3490297db 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -12,6 +12,7 @@ import { Category } from './Category'; import { Tag } from './Tag'; +import { HttpFile } from '../http/http'; /** * A pet for sale in the pet store diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index 53576de1f9d3..ce2a0e6d2a80 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index 71276892aa0b..049af95de370 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A User who is purchasing from the pet store diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts index 4882a9d216da..e786d5ed8b9b 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -45,7 +45,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; @@ -259,7 +259,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); let authMethod = null; @@ -385,14 +385,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { export class PetApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to addPet + * @throws ApiException if the response code was not in [200, 299] + */ public addPet(response: ResponseContext): void { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); @@ -406,13 +406,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deletePet + * @throws ApiException if the response code was not in [200, 299] + */ public deletePet(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); @@ -426,13 +426,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByStatus + * @throws ApiException if the response code was not in [200, 299] + */ public findPetsByStatus(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -453,13 +453,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByTags + * @throws ApiException if the response code was not in [200, 299] + */ public findPetsByTags(response: ResponseContext): Array { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -480,13 +480,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getPetById + * @throws ApiException if the response code was not in [200, 299] + */ public getPetById(response: ResponseContext): Pet { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -510,13 +510,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePet + * @throws ApiException if the response code was not in [200, 299] + */ public updatePet(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); @@ -536,13 +536,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePetWithForm + * @throws ApiException if the response code was not in [200, 299] + */ public updatePetWithForm(response: ResponseContext): void { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); @@ -556,13 +556,13 @@ export class PetApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to uploadFile + * @throws ApiException if the response code was not in [200, 299] + */ public uploadFile(response: ResponseContext): ApiResponse { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index 4a6a03856459..89a778f6dffc 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -149,7 +149,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -162,14 +162,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { export class StoreApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteOrder + * @throws ApiException if the response code was not in [200, 299] + */ public deleteOrder(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); @@ -186,13 +186,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getInventory + * @throws ApiException if the response code was not in [200, 299] + */ public getInventory(response: ResponseContext): { [key: string]: number; } { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -210,13 +210,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getOrderById + * @throws ApiException if the response code was not in [200, 299] + */ public getOrderById(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -240,13 +240,13 @@ export class StoreApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to placeOrder + * @throws ApiException if the response code was not in [200, 299] + */ public placeOrder(response: ResponseContext): Order { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts index bff513b7807b..39b12334412d 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -45,7 +45,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -84,7 +84,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -123,7 +123,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -316,7 +316,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { requestContext.setHeaderParam("Content-Type", "application/json"); // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body.toString() || ""); // TODO: `toString` call is unnecessary + const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary requestContext.setBody(serializedBody); // Apply auth methods @@ -329,14 +329,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { export class UserApiResponseProcessor { - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUser + * @throws ApiException if the response code was not in [200, 299] + */ public createUser(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -350,13 +350,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithArrayInput + * @throws ApiException if the response code was not in [200, 299] + */ public createUsersWithArrayInput(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -370,13 +370,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithListInput + * @throws ApiException if the response code was not in [200, 299] + */ public createUsersWithListInput(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -390,13 +390,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteUser + * @throws ApiException if the response code was not in [200, 299] + */ public deleteUser(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); @@ -413,13 +413,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getUserByName + * @throws ApiException if the response code was not in [200, 299] + */ public getUserByName(response: ResponseContext): User { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -443,13 +443,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to loginUser + * @throws ApiException if the response code was not in [200, 299] + */ public loginUser(response: ResponseContext): string { if (isCodeInRange("200", response.httpStatusCode)) { const jsonBody = JSON.parse(response.body); @@ -470,13 +470,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to logoutUser + * @throws ApiException if the response code was not in [200, 299] + */ public logoutUser(response: ResponseContext): void { if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); @@ -490,13 +490,13 @@ export class UserApiResponseProcessor { throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to - * @throws ApiException if the response code was not in [200, 299] - */ + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateUser + * @throws ApiException if the response code was not in [200, 299] + */ public updateUser(response: ResponseContext): void { if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 1071360efbc4..2fe01724d507 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -6,7 +6,7 @@ import { Observable } from '../rxjsStub'; export * from './jquery'; /** - * Represents a HTTP Method. + * Represents an HTTP method. */ export enum HttpMethod { GET = "GET", @@ -21,7 +21,7 @@ export enum HttpMethod { } /** - * Represents a http file which will be uploaded to a server. + * Represents an HTTP file which will be transferred from or to a server. */ export type HttpFile = Blob & { readonly name: string }; @@ -33,14 +33,18 @@ export class HttpException extends Error { } /** - * Represents a HTTP request context - * + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData; + +/** + * Represents an HTTP request context */ export class RequestContext { private headers: { [key: string]: string } = {}; - private body: string | FormData = ""; - private url: URLParse; - + private body: RequestBody = undefined; + private url: URLParse; + /** * Creates the request context using a http method and request resource url * @@ -67,27 +71,19 @@ export class RequestContext { this.url = URLParse(url, true); } - /** * Sets the body of the http request either as a string or FormData - * Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section - * 4.3 and this method throws an HttpException accordingly. + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 * * @param body the body of the request */ - public setBody(body: string | FormData) { - // HTTP-Spec 1.1 Section 4.3 - if (this.httpMethod === HttpMethod.GET) { - throw new HttpException("Body should not be included in GET-Requests!"); - } - - // TODO: other http methods - - // post is fine either formData or string + public setBody(body: RequestBody) { this.body = body; - } - + public getHttpMethod(): HttpMethod { return this.httpMethod; } @@ -95,9 +91,9 @@ export class RequestContext { public getHeaders(): { [key: string]: string } { return this.headers; } - - public getBody(): string | FormData { - return this.body; + + public getBody(): RequestBody { + return this.body; } public setQueryParam(name: string, value: string) { diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts index 30bd09f56caf..4b144a79e2c6 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -37,7 +37,7 @@ export class JQueryHttpLibrary implements HttpLibrary { throw new HttpException("Setting the \"Cookie\"-Header field is blocked by every major browser when using jquery.ajax requests. Please switch to another library like fetch to enable this option"); } - if (body.constructor.name == "FormData") { + if (body && body.constructor.name == "FormData") { requestOptions.contentType = false; } const sentRequest = $.ajax(requestOptions); diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/client/petstore/typescript/builds/jquery/index.ts index 44c085d2dd07..fd12234aa0ec 100644 --- a/samples/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/client/petstore/typescript/builds/jquery/index.ts @@ -1,7 +1,9 @@ export * from './http/http'; export * from './auth/auth'; -export {Middleware, PromiseMiddleware} from './middleware'; export * from './models/all'; export { Configuration} from './configuration' -export * from './types/PromiseAPI'; -export * from './apis/exception'; \ No newline at end of file +export * from './apis/exception'; +export * from './servers'; + + export * from './types/PromiseAPI'; + export { PromiseMiddleware as Middleware } from './middleware'; diff --git a/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts index 1e4383431b77..300b2de4d9a9 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/client/petstore/typescript/builds/jquery/models/Category.ts index 69d6879fb9bd..9b210d5d501d 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/Category.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/Category.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A category for a pet diff --git a/samples/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/client/petstore/typescript/builds/jquery/models/Order.ts index 0ef6a1dbef14..291018b9e065 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/Order.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/Order.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/client/petstore/typescript/builds/jquery/models/Pet.ts index cf45a4341f34..77a3490297db 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/Pet.ts @@ -12,6 +12,7 @@ import { Category } from './Category'; import { Tag } from './Tag'; +import { HttpFile } from '../http/http'; /** * A pet for sale in the pet store diff --git a/samples/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/client/petstore/typescript/builds/jquery/models/Tag.ts index 53576de1f9d3..ce2a0e6d2a80 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/Tag.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript/builds/jquery/models/User.ts b/samples/client/petstore/typescript/builds/jquery/models/User.ts index 71276892aa0b..049af95de370 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/User.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/User.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { HttpFile } from '../http/http'; /** * A User who is purchasing from the pet store diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts index 0a7dafc96966..e163cf156bc6 100644 --- a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -12,7 +12,7 @@ describe("Security Authentication", () => { expect(ctx.getUrl()).to.equal("http://google.com"); expect(ctx.getHeaders()).to.deep.equal({}); - expect(ctx.getBody()).to.equal(""); + expect(ctx.getBody()).to.equal(undefined); }); }) @@ -26,7 +26,7 @@ describe("Security Authentication", () => { expect(ctx.getUrl()).to.equal("http://google.com"); expect(ctx.getHeaders()).to.have.property("paramName"); expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); - expect(ctx.getBody()).to.equal(""); + expect(ctx.getBody()).to.equal(undefined); }); it("Query API Key", () => { @@ -36,7 +36,7 @@ describe("Security Authentication", () => { expect(ctx.getUrl()).to.contain("paramName=apiKey"); expect(ctx.getHeaders()).to.deep.equal({}); - expect(ctx.getBody()).to.equal(""); + expect(ctx.getBody()).to.equal(undefined); }); it("Cookie API Key", () => { @@ -47,7 +47,7 @@ describe("Security Authentication", () => { expect(ctx.getUrl()).to.equal("http://google.com"); expect(ctx.getHeaders()).to.have.property("Cookie"); expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); - expect(ctx.getBody()).to.equal(""); + expect(ctx.getBody()).to.equal(undefined); }); }) From e315d486365ccbfc25e98a5b1876d2c7ee65a320 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 22 May 2020 21:54:52 +0200 Subject: [PATCH 66/85] Support media types other than json (#6177) List of changes: * Add */* as fallback to accept header * Use more sophisticated media type selection * Handle object stringify in ObjectSerializer * Parse response with ObejctSerializer * Fix: Correctly extract response headers in browser * Create HttpFile objects from responses * Handle binary responses * Clean up dependencies and replace isomorphic-fetch Instead of isomorphic-fetch, which is unmaintained, we directly use node-fetch and whatwg-fetch polyfills. --- .../resources/typescript/api/api.mustache | 67 +- .../resources/typescript/http/http.mustache | 102 +- .../typescript/http/isomorphic-fetch.mustache | 47 +- .../resources/typescript/http/jquery.mustache | 29 +- .../main/resources/typescript/index.mustache | 2 + .../model/ObjectSerializer.mustache | 75 ++ .../resources/typescript/package.mustache | 11 +- .../resources/typescript/tsconfig.mustache | 7 + .../typescript/builds/default/apis/PetApi.ts | 172 +-- .../builds/default/apis/StoreApi.ts | 94 +- .../typescript/builds/default/apis/UserApi.ts | 160 +-- .../typescript/builds/default/http/http.ts | 64 +- .../builds/default/http/isomorphic-fetch.ts | 27 +- .../typescript/builds/default/index.ts | 2 + .../builds/default/models/ObjectSerializer.ts | 75 ++ .../builds/default/package-lock.json | 78 +- .../typescript/builds/default/package.json | 4 +- .../typescript/builds/default/tsconfig.json | 2 +- .../typescript/builds/jquery/apis/PetApi.ts | 172 +-- .../typescript/builds/jquery/apis/StoreApi.ts | 94 +- .../typescript/builds/jquery/apis/UserApi.ts | 160 +-- .../typescript/builds/jquery/http/http.ts | 84 +- .../typescript/builds/jquery/http/jquery.ts | 24 +- .../typescript/builds/jquery/index.ts | 2 + .../builds/jquery/models/ObjectSerializer.ts | 75 ++ .../builds/jquery/package-lock.json | 6 +- .../tests/default/package-lock.json | 88 +- .../test/http/isomorphic-fetch.test.ts | 30 +- .../typescript/tests/jquery/package-lock.json | 999 ++++++------------ 29 files changed, 1527 insertions(+), 1225 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index c74876f1242a..8e4b6d52a531 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -52,7 +52,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params {{#queryParams}} @@ -96,9 +96,9 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#node}} localVarFormParams.append('{{baseName}}', {{paramName}}.data, {{paramName}}.name); {{/node}} - {{^node}} + {{#browser}} localVarFormParams.append('{{baseName}}', {{paramName}}, {{paramName}}.name); - {{/node}} + {{/browser}} {{/platforms}} {{/isFile}} } @@ -110,15 +110,14 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Body Params {{#bodyParam}} - {{^consumes}} - requestContext.setHeaderParam("Content-Type", "application/json"); - {{/consumes}} - {{#consumes.0}} - requestContext.setHeaderParam("Content-Type", "{{{mediaType}}}"); - {{/consumes.0}} - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("{{dataType}}" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([{{#consumes}} + "{{{mediaType}}}"{{#hasMore}},{{/hasMore}} + {{/consumes}}]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}"), + contentType + ); requestContext.setBody(serializedBody); {{/bodyParam}} @@ -153,12 +152,20 @@ export class {{classname}}ResponseProcessor { * @params response Response returned by the server for a request to {{nickname}} * @throws ApiException if the response code was not in [200, 299] */ - public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { + public async {{nickname}}(response: ResponseContext): Promise<{{#returnType}}{{{returnType}}}{{/returnType}} {{^returnType}}void{{/returnType}}> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); {{#responses}} if (isCodeInRange("{{code}}", response.httpStatusCode)) { {{#dataType}} - const jsonBody = JSON.parse(response.body); - const body: {{{dataType}}} = ObjectSerializer.deserialize(jsonBody, "{{{dataType}}}", "{{returnFormat}}") as {{{dataType}}}; + {{#isBinary}} + const body: {{{dataType}}} = await response.getBodyAsFile() as any as {{{returnType}}}; + {{/isBinary}} + {{^isBinary}} + const body: {{{dataType}}} = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{{{dataType}}}", "{{returnFormat}}" + ) as {{{dataType}}}; + {{/isBinary}} {{#isSuccessCode}} return body; {{/isSuccessCode}} @@ -173,21 +180,29 @@ export class {{classname}}ResponseProcessor { {{^isSuccessCode}} throw new ApiException(response.httpStatusCode, "{{message}}"); {{/isSuccessCode}} - {{/dataType}} + {{/dataType}} } {{/responses}} - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - {{#returnType}} - const jsonBody = JSON.parse(response.body); - const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}", "{{returnFormat}}") as {{{returnType}}}; - return body; - {{/returnType}} - {{^returnType}} - return; - {{/returnType}} + {{#returnType}} + {{#isBinary}} + const body: {{{returnType}}} = await response.getBodyAsFile() as any as {{{returnType}}}; + {{/isBinary}} + {{^isBinary}} + const body: {{{returnType}}} = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{{{returnType}}}", "{{returnFormat}}" + ) as {{{returnType}}}; + {{/isBinary}} + return body; + {{/returnType}} + {{^returnType}} + return; + {{/returnType}} } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 2850e31dabb1..66bdb2e5c2c1 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -43,9 +43,9 @@ export type HttpFile = { name: string }; {{/node}} -{{^node}} +{{#browser}} export type HttpFile = {{{fileContentDataType}}} & { readonly name: string }; -{{/node}} +{{/browser}} {{/platforms}} @@ -141,12 +141,104 @@ export class RequestContext { } } +export interface ResponseBody { + text(): Promise; + binary(): Promise<{{{fileContentDataType}}}>; +} + + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise<{{{fileContentDataType}}}>) {} + + binary(): Promise<{{{fileContentDataType}}}> { + return this.dataSource; + } + + async text(): Promise { + const data: {{{fileContentDataType}}} = await this.dataSource; + {{#platforms}} + {{#node}} + return data.toString(); + {{/node}} + {{#browser}} + // @ts-ignore + if (data.text) { + // @ts-ignore + return data.text(); + } + + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("error", () => reject(reader.error)); + reader.readAsText(data); + }); + {{/browser}} + {{/platforms}} + } +} + export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + {{#platforms}} + {{#node}} + return { data, name: fileName }; + {{/node}} + {{#browser}} + const contentType = this.headers["content-type"] || ""; + try { + return new File([data], fileName, { type: contentType }); + } catch (error) { + /** Fallback for when the File constructor is not available */ + return Object.assign(data, { + name: fileName, + type: contentType + }); + } + {{/browser}} + {{/platforms}} } - } export interface HttpLibrary { diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index f25e141554e9..691b8187ccde 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,33 +1,52 @@ -declare var fetch: any; - import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import 'es6-promise/auto'; import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; -import 'isomorphic-fetch'; +{{#platforms}} +{{#node}} +import fetch from "node-fetch"; +{{/node}} +{{#browser}} +import "whatwg-fetch"; +{{/browser}} +{{/platforms}} export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), + {{#platforms}} + {{#browser}} credentials: "same-origin" + {{/browser}} + {{/platforms}} }).then((resp: any) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body: string) => { - return new ResponseContext(resp.status, headers, body) + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; }); + + {{#platforms}} + {{#node}} + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + {{/node}} + {{^node}} + const body = { + text: () => resp.text(), + binary: () => resp.blob() + }; + {{/node}} + {{/platforms}} + return new ResponseContext(resp.status, headers, body); }); - + return from>(resultPromise); } diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index 63fc7d39185a..d6a25d993ec2 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -1,13 +1,9 @@ -import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import { HttpLibrary, RequestContext, ResponseContext, HttpException, SelfDecodingBody } from './http'; import * as e6p from 'es6-promise' import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; e6p.polyfill(); import * as $ from 'jquery'; -{{#platforms}} -{{#node}} -import * as FormData from "form-data"; -{{/node}} -{{/platforms}} + export class JQueryHttpLibrary implements HttpLibrary { @@ -21,10 +17,20 @@ export class JQueryHttpLibrary implements HttpLibrary { type: method, headers: request.getHeaders(), processData: false, - xhrFields: { withCredentials: true }, + xhrFields: { withCredentials: true }, data: body }; + /** + * Allow receiving binary data with jquery ajax + * + * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ + */ + requestOptions.beforeSend = (jqXHR: any, settings: any) => { + settings.xhr().responseType = "blob"; + }; + + if (request.getHeaders()['Content-Type']) { requestOptions.contentType = headerParams['Content-Type']; } @@ -48,9 +54,12 @@ export class JQueryHttpLibrary implements HttpLibrary { const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { - sentRequest.done((resp, _, jqXHR) => { - const headers = this.getResponseHeaders(jqXHR) - const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + sentRequest.done((data, _, jqXHR) => { + const result = new ResponseContext( + jqXHR.status, + this.getResponseHeaders(jqXHR), + new SelfDecodingBody(Promise.resolve(data)) + ); resolve(result); }) sentRequest.fail((jqXHR: any) => { diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache index b1e833cf960b..3ac251c10ce6 100644 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index e751e2d047c6..5a14d7ac3440 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -21,6 +21,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ {{#models}} @@ -162,4 +168,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 67d117572084..608318ea2dfc 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -19,8 +19,15 @@ "dependencies": { {{#frameworks}} {{#fetch-api}} - "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34", + {{#platforms}} + {{#node}} + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", + {{/node}} + {{#browser}} + "whatwg-fetch": "^3.0.0", + {{/browser}} + {{/platforms}} {{/fetch-api}} {{#jquery}} "@types/jquery": "^3.3.29", diff --git a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache index 103a5de86358..5831f2409da0 100644 --- a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache @@ -16,7 +16,14 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, + {{#platforms}} + {{#node}} + "lib": [ "es6" ] + {{/node}} + {{#browser}} "lib": [ "es6", "dom" ] + {{/browser}} + {{/platforms}} }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 8744f0909be1..f86ca7a612e7 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -33,7 +33,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -43,10 +43,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -80,7 +86,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -121,7 +127,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (status !== undefined) { @@ -164,7 +170,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (tags !== undefined) { @@ -208,7 +214,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -247,7 +253,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -257,10 +263,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -296,7 +308,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -350,7 +362,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -394,15 +406,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public addPet(response: ResponseContext): void { + public async addPet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -414,15 +428,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to deletePet * @throws ApiException if the response code was not in [200, 299] */ - public deletePet(response: ResponseContext): void { + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -434,22 +450,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByStatus * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByStatus(response: ResponseContext): Array { + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid status value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -461,22 +483,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByTags * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByTags(response: ResponseContext): Array { + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid tag value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -488,10 +516,13 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to getPetById * @throws ApiException if the response code was not in [200, 299] */ - public getPetById(response: ResponseContext): Pet { + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -500,13 +531,16 @@ export class PetApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Pet not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; - return body; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -518,7 +552,8 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public updatePet(response: ResponseContext): void { + public async updatePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -528,11 +563,12 @@ export class PetApiResponseProcessor { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Validation exception"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -544,15 +580,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePetWithForm * @throws ApiException if the response code was not in [200, 299] */ - public updatePetWithForm(response: ResponseContext): void { + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -564,19 +602,25 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to uploadFile * @throws ApiException if the response code was not in [200, 299] */ - public uploadFile(response: ResponseContext): ApiResponse { + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; - return body; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 2168c95ddb90..6e92f2ac33f7 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -34,7 +34,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -62,7 +62,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -103,7 +103,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -137,7 +137,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -147,10 +147,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Order", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -171,18 +173,20 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to deleteOrder * @throws ApiException if the response code was not in [200, 299] */ - public deleteOrder(response: ResponseContext): void { + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -194,19 +198,25 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getInventory * @throws ApiException if the response code was not in [200, 299] */ - public getInventory(response: ResponseContext): { [key: string]: number; } { + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; - return body; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -218,10 +228,13 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getOrderById * @throws ApiException if the response code was not in [200, 299] */ - public getOrderById(response: ResponseContext): Order { + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -230,13 +243,16 @@ export class StoreApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -248,22 +264,28 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to placeOrder * @throws ApiException if the response code was not in [200, 299] */ - public placeOrder(response: ResponseContext): Order { + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid Order"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index 9a4c150a22fe..efce92585dcb 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -33,7 +33,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -43,10 +43,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -72,7 +74,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -82,10 +84,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -111,7 +115,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -121,10 +125,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -152,7 +158,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -187,7 +193,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -228,7 +234,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (username !== undefined) { @@ -261,7 +267,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -304,7 +310,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -314,10 +320,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -338,15 +346,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUser * @throws ApiException if the response code was not in [200, 299] */ - public createUser(response: ResponseContext): void { + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -358,15 +368,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithArrayInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithArrayInput(response: ResponseContext): void { + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -378,15 +390,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithListInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithListInput(response: ResponseContext): void { + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -398,18 +412,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to deleteUser * @throws ApiException if the response code was not in [200, 299] */ - public deleteUser(response: ResponseContext): void { + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -421,10 +437,13 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to getUserByName * @throws ApiException if the response code was not in [200, 299] */ - public getUserByName(response: ResponseContext): User { + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -433,13 +452,16 @@ export class UserApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; - return body; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -451,22 +473,28 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to loginUser * @throws ApiException if the response code was not in [200, 299] */ - public loginUser(response: ResponseContext): string { + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; - return body; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -478,15 +506,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to logoutUser * @throws ApiException if the response code was not in [200, 299] */ - public logoutUser(response: ResponseContext): void { + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -498,18 +528,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to updateUser * @throws ApiException if the response code was not in [200, 299] */ - public updateUser(response: ResponseContext): void { + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 7549c847aa3a..6de17431aa26 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -123,12 +123,70 @@ export class RequestContext { } } +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; } - } export interface HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index f7e6474c2532..ed390df7ce10 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -1,33 +1,30 @@ -declare var fetch: any; - import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import 'es6-promise/auto'; import { from, Observable } from '../rxjsStub'; -import 'isomorphic-fetch'; +import fetch from "node-fetch"; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), - credentials: "same-origin" }).then((resp: any) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body: string) => { - return new ResponseContext(resp.status, headers, body) + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); }); - + return from>(resultPromise); } diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index fd12234aa0ec..575141afce11 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index f6ca619bf10b..6eef999baaa3 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -23,6 +23,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ "OrderStatusEnum", @@ -156,4 +162,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index e91cff7ebba9..94caf0f4b222 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -4,16 +4,32 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/isomorphic-fetch": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", - "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" - }, "@types/node": { "version": "12.12.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -37,14 +53,6 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, "es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", @@ -60,28 +68,6 @@ "mime-types": "^2.1.12" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -96,13 +82,9 @@ } }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.0", @@ -114,14 +96,9 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, "typescript": { "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "resolved": false, "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", "dev": true }, @@ -133,11 +110,6 @@ "querystringify": "^2.0.0", "requires-port": "^1.0.0" } - }, - "whatwg-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } } diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index 70b348648e12..7bcc9bd25a18 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -17,8 +17,8 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34", + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", "@types/node": "*", "form-data": "^2.5.0", "btoa": "^1.2.1", diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json index 142f3fa631a3..0f376008e1a6 100644 --- a/samples/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -16,7 +16,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6", "dom" ] + "lib": [ "es6" ] }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts index e786d5ed8b9b..6fec1ad3d232 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -32,7 +32,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -42,10 +42,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -79,7 +85,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -120,7 +126,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (status !== undefined) { @@ -163,7 +169,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (tags !== undefined) { @@ -207,7 +213,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -246,7 +252,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -256,10 +262,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -295,7 +307,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -349,7 +361,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -393,15 +405,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public addPet(response: ResponseContext): void { + public async addPet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -413,15 +427,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to deletePet * @throws ApiException if the response code was not in [200, 299] */ - public deletePet(response: ResponseContext): void { + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -433,22 +449,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByStatus * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByStatus(response: ResponseContext): Array { + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid status value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -460,22 +482,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByTags * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByTags(response: ResponseContext): Array { + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid tag value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -487,10 +515,13 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to getPetById * @throws ApiException if the response code was not in [200, 299] */ - public getPetById(response: ResponseContext): Pet { + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -499,13 +530,16 @@ export class PetApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Pet not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; - return body; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -517,7 +551,8 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public updatePet(response: ResponseContext): void { + public async updatePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -527,11 +562,12 @@ export class PetApiResponseProcessor { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Validation exception"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -543,15 +579,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePetWithForm * @throws ApiException if the response code was not in [200, 299] */ - public updatePetWithForm(response: ResponseContext): void { + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -563,19 +601,25 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to uploadFile * @throws ApiException if the response code was not in [200, 299] */ - public uploadFile(response: ResponseContext): ApiResponse { + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; - return body; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index 89a778f6dffc..c7cca9dc1d89 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -33,7 +33,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -61,7 +61,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -102,7 +102,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -136,7 +136,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -146,10 +146,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Order", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -170,18 +172,20 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to deleteOrder * @throws ApiException if the response code was not in [200, 299] */ - public deleteOrder(response: ResponseContext): void { + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -193,19 +197,25 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getInventory * @throws ApiException if the response code was not in [200, 299] */ - public getInventory(response: ResponseContext): { [key: string]: number; } { + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; - return body; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -217,10 +227,13 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getOrderById * @throws ApiException if the response code was not in [200, 299] */ - public getOrderById(response: ResponseContext): Order { + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -229,13 +242,16 @@ export class StoreApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -247,22 +263,28 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to placeOrder * @throws ApiException if the response code was not in [200, 299] */ - public placeOrder(response: ResponseContext): Order { + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid Order"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts index 39b12334412d..46222492ed85 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -32,7 +32,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -42,10 +42,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -71,7 +73,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -81,10 +83,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -110,7 +114,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -120,10 +124,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -151,7 +157,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -186,7 +192,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -227,7 +233,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (username !== undefined) { @@ -260,7 +266,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -303,7 +309,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -313,10 +319,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -337,15 +345,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUser * @throws ApiException if the response code was not in [200, 299] */ - public createUser(response: ResponseContext): void { + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -357,15 +367,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithArrayInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithArrayInput(response: ResponseContext): void { + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -377,15 +389,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithListInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithListInput(response: ResponseContext): void { + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -397,18 +411,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to deleteUser * @throws ApiException if the response code was not in [200, 299] */ - public deleteUser(response: ResponseContext): void { + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -420,10 +436,13 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to getUserByName * @throws ApiException if the response code was not in [200, 299] */ - public getUserByName(response: ResponseContext): User { + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -432,13 +451,16 @@ export class UserApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; - return body; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -450,22 +472,28 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to loginUser * @throws ApiException if the response code was not in [200, 299] */ - public loginUser(response: ResponseContext): string { + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; - return body; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -477,15 +505,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to logoutUser * @throws ApiException if the response code was not in [200, 299] */ - public logoutUser(response: ResponseContext): void { + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -497,18 +527,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to updateUser * @throws ApiException if the response code was not in [200, 299] */ - public updateUser(response: ResponseContext): void { + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 2fe01724d507..225d72814d7d 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -118,12 +118,90 @@ export class RequestContext { } } +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Blob = await this.dataSource; + // @ts-ignore + if (data.text) { + // @ts-ignore + return data.text(); + } + + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("error", () => reject(reader.error)); + reader.readAsText(data); + }); + } +} + export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + const contentType = this.headers["content-type"] || ""; + try { + return new File([data], fileName, { type: contentType }); + } catch (error) { + /** Fallback for when the File constructor is not available */ + return Object.assign(data, { + name: fileName, + type: contentType + }); + } } - } export interface HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts index 4b144a79e2c6..238eef3be089 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -1,9 +1,10 @@ -import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import { HttpLibrary, RequestContext, ResponseContext, HttpException, SelfDecodingBody } from './http'; import * as e6p from 'es6-promise' import { from, Observable } from '../rxjsStub'; e6p.polyfill(); import * as $ from 'jquery'; + export class JQueryHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { @@ -16,10 +17,20 @@ export class JQueryHttpLibrary implements HttpLibrary { type: method, headers: request.getHeaders(), processData: false, - xhrFields: { withCredentials: true }, + xhrFields: { withCredentials: true }, data: body }; + /** + * Allow receiving binary data with jquery ajax + * + * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ + */ + requestOptions.beforeSend = (jqXHR: any, settings: any) => { + settings.xhr().responseType = "blob"; + }; + + if (request.getHeaders()['Content-Type']) { requestOptions.contentType = headerParams['Content-Type']; } @@ -43,9 +54,12 @@ export class JQueryHttpLibrary implements HttpLibrary { const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { - sentRequest.done((resp, _, jqXHR) => { - const headers = this.getResponseHeaders(jqXHR) - const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + sentRequest.done((data, _, jqXHR) => { + const result = new ResponseContext( + jqXHR.status, + this.getResponseHeaders(jqXHR), + new SelfDecodingBody(Promise.resolve(data)) + ); resolve(result); }) sentRequest.fail((jqXHR: any) => { diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/client/petstore/typescript/builds/jquery/index.ts index fd12234aa0ec..575141afce11 100644 --- a/samples/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/client/petstore/typescript/builds/jquery/index.ts @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index f6ca619bf10b..6eef999baaa3 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -23,6 +23,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ "OrderStatusEnum", @@ -156,4 +162,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/client/petstore/typescript/builds/jquery/package-lock.json index cdbe4eeddc48..dd9642223ad4 100644 --- a/samples/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/client/petstore/typescript/builds/jquery/package-lock.json @@ -28,9 +28,9 @@ "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, "jquery": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", - "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "querystringify": { "version": "2.1.1", diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 23c63616b5da..6bd3eb97155e 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -34,9 +34,9 @@ "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" }, "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" }, "acorn-jsx": { "version": "3.0.1", @@ -748,9 +748,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lru-cache": { "version": "4.1.5", @@ -803,23 +803,16 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - } + "minimist": "^1.2.5" } }, "mocha": { @@ -841,6 +834,21 @@ "supports-color": "5.4.0" }, "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -1215,12 +1223,11 @@ "ts-petstore-client": { "version": "file:../../builds/default", "requires": { - "@types/isomorphic-fetch": "0.0.34", "@types/node": "*", "btoa": "^1.2.1", "es6-promise": "^4.2.4", "form-data": "^2.5.0", - "isomorphic-fetch": "^2.2.1", + "node-fetch": "^2.6.0", "url-parse": "^1.4.3" }, "dependencies": { @@ -1257,14 +1264,6 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, "es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", @@ -1280,25 +1279,11 @@ "mime-types": "^2.1.12" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, "isomorphic-fetch": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "requires": { - "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" } }, @@ -1316,13 +1301,9 @@ } }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.0", @@ -1334,11 +1315,6 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, "typescript": { "version": "2.9.2", "resolved": false, diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index 974ebd2d1348..7c4e142747fd 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -18,17 +18,15 @@ for (let libName in libs) { requestContext.addCookie("test-cookie", "cookie-value"); lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["headers"]).to.exist; expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); done(); - }, - (e: any) => { - done(e); - } - ) - }) + }).catch(done) + }); it("POST-Request", (done) => { let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST); @@ -42,17 +40,16 @@ for (let libName in libs) { lib.send(requestContext).toPromise().then( (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["headers"]).to.exist; expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); expect(body["files"]["testFile"]).to.equal("abc"); expect(body["form"]["test"]).to.equal("test2"); done(); - }, - (e: any) => { - done(e); - }) + }).catch(done) }); it("Cookies-Request", (done) => { @@ -62,13 +59,12 @@ for (let libName in libs) { lib.send(requestContext).toPromise().then( (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); done(); - }, - (e: any) => { - done(e); - }) + }).catch(done) }) }) } \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index 75916fc87813..b947dee27386 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -216,9 +216,9 @@ "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==" }, "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==" }, "acorn-globals": { "version": "4.3.2", @@ -250,9 +250,9 @@ "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==" }, "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "requires": { "es6-promisify": "^5.0.0" } @@ -294,22 +294,13 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "optional": true, "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" } }, "aproba": { @@ -410,7 +401,8 @@ "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==" + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "optional": true }, "async-limiter": { "version": "1.0.0", @@ -543,14 +535,15 @@ "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" }, "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "optional": true }, "bluebird": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.1.tgz", - "integrity": "sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==" + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, "bn.js": { "version": "4.11.8", @@ -678,6 +671,11 @@ "isarray": "^1.0.0" } }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -694,9 +692,9 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" }, "cacache": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz", - "integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.4.tgz", + "integrity": "sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ==", "requires": { "bluebird": "^3.5.5", "chownr": "^1.1.1", @@ -816,28 +814,60 @@ "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" }, "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", + "integrity": "sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ==", + "optional": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.4.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "optional": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "optional": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "optional": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "optional": true, + "requires": { + "is-number": "^7.0.0" + } + } } }, "chownr": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", - "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "chrome-trace-event": { "version": "1.0.2", @@ -1318,9 +1348,9 @@ } }, "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "es6-promisify": { "version": "5.0.0", @@ -1447,9 +1477,9 @@ }, "dependencies": { "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" } } }, @@ -1673,14 +1703,14 @@ } }, "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", - "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", + "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", + "requires": { + "concat-stream": "^1.6.2", + "debug": "^2.6.9", + "mkdirp": "^0.5.4", + "yauzl": "^2.10.0" }, "dependencies": { "debug": { @@ -1719,17 +1749,17 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "requires": { "pend": "~1.2.0" } }, "figgy-pudding": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", - "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==" + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", + "integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw==" }, "figures": { "version": "2.0.0", @@ -1872,485 +1902,10 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", - "optional": true, - "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "bundled": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "bundled": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "optional": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "optional": true - }, - "minipass": { - "version": "2.3.5", - "bundled": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "bundled": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "bundled": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "bundled": true, - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "bundled": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "bundled": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "bundled": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.3", - "bundled": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "optional": true - }, - "semver": { - "version": "5.7.0", - "bundled": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "optional": true - }, - "tar": { - "version": "4.4.8", - "bundled": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "bundled": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "yallist": { - "version": "3.0.3", - "bundled": true, - "optional": true - } - } + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "optional": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -2397,22 +1952,12 @@ } }, "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "optional": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } - } + "is-glob": "^4.0.1" } }, "global-modules": { @@ -2573,11 +2118,11 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" }, "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", + "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "requires": { - "agent-base": "^4.1.0", + "agent-base": "^4.3.0", "debug": "^3.1.0" }, "dependencies": { @@ -2702,11 +2247,12 @@ } }, "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "optional": true, "requires": { - "binary-extensions": "^1.0.0" + "binary-extensions": "^2.0.0" } }, "is-buffer": { @@ -2953,9 +2499,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } }, @@ -2971,9 +2517,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" }, "lcid": { "version": "2.0.0", @@ -3017,9 +2563,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash.sortby": { "version": "4.7.0", @@ -3141,9 +2687,9 @@ } }, "mime": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", - "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.5.tgz", + "integrity": "sha512-3hQhEUF027BuxZjQA3s7rIv/7VCQPa27hN9u9g87sEkWaKwQPuXOkVKtOeiyUrnWqTDiOs8Ed2rwg733mB0R5w==" }, "mime-db": { "version": "1.40.0", @@ -3182,9 +2728,9 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mississippi": { "version": "3.0.0", @@ -3204,9 +2750,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -3223,11 +2769,11 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "move-concurrently": { @@ -3253,12 +2799,6 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "optional": true - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -3346,7 +2886,8 @@ "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "optional": true }, "npm-run-path": { "version": "2.0.2", @@ -3551,7 +3092,8 @@ "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=" + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "optional": true }, "path-exists": { "version": "3.0.0", @@ -3600,6 +3142,12 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "optional": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -3654,9 +3202,9 @@ "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" }, "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "prr": { "version": "1.0.1", @@ -3722,9 +3270,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "puppeteer": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz", - "integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz", + "integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==", "requires": { "debug": "^4.1.0", "extract-zip": "^1.6.6", @@ -3841,13 +3389,12 @@ } }, "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", + "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", + "optional": true, "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" + "picomatch": "^2.2.1" } }, "regex-not": { @@ -3867,7 +3414,8 @@ "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=" + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "optional": true }, "repeat-element": { "version": "1.1.3", @@ -4145,9 +3693,9 @@ "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, "serialize-javascript": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", - "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", + "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==" }, "set-blocking": { "version": "2.0.0", @@ -4155,9 +3703,9 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -4464,9 +4012,9 @@ } }, "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, "string-width": { "version": "2.1.1", @@ -4567,9 +4115,9 @@ "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==" }, "terser": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz", - "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==", + "version": "4.6.13", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.13.tgz", + "integrity": "sha512-wMvqukYgVpQlymbnNbabVZbtM6PN63AzqexpwJL8tbh/mRT9LE5o+ruVduAGL7D6Fpjl+Q+06U5I9Ul82odAhw==", "requires": { "commander": "^2.20.0", "source-map": "~0.6.1", @@ -4582,9 +4130,9 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "source-map-support": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", - "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -4593,15 +4141,15 @@ } }, "terser-webpack-plugin": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz", - "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz", + "integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==", "requires": { "cacache": "^12.0.2", "find-cache-dir": "^2.1.0", "is-wsl": "^1.1.0", "schema-utils": "^1.0.0", - "serialize-javascript": "^1.7.0", + "serialize-javascript": "^2.1.2", "source-map": "^0.6.1", "terser": "^4.1.2", "webpack-sources": "^1.4.0", @@ -4734,9 +4282,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } }, @@ -4746,7 +4294,7 @@ "@types/jquery": "^3.3.29", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "jquery": "^3.4.1", + "jquery": "^3.5.1", "url-parse": "^1.4.3" }, "dependencies": { @@ -4928,9 +4476,9 @@ } }, "jquery": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", - "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "mime-db": { "version": "1.40.0", @@ -5036,35 +4584,14 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-filename": { @@ -5122,7 +4649,8 @@ "upath": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", + "optional": true }, "uri-js": { "version": "4.2.2", @@ -5223,13 +4751,119 @@ } }, "watchpack": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", - "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.2.tgz", + "integrity": "sha512-ymVbbQP40MFTp+cNMvpyBpBtygHnPzPkHqoIwRRj/0B8KhqQwV8LaKjtbaxF2lK4vl8zN9wCxS46IFCU5K4W0g==", "requires": { - "chokidar": "^2.0.2", + "chokidar": "^3.4.0", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0" + "neo-async": "^2.5.0", + "watchpack-chokidar2": "^2.0.0" + } + }, + "watchpack-chokidar2": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/watchpack-chokidar2/-/watchpack-chokidar2-2.0.0.tgz", + "integrity": "sha512-9TyfOyN/zLUbA288wZ8IsMZ+6cbzvsNyEzSBp6e/zkifi6xxbl8SmQ/CxQq32k8NNqrdVEVUVSEf56L4rQ/ZxA==", + "optional": true, + "requires": { + "chokidar": "^2.1.8" + }, + "dependencies": { + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "optional": true + }, + "chokidar": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "optional": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } + }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "optional": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "optional": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + } } }, "webidl-conversions": { @@ -5268,9 +4902,9 @@ }, "dependencies": { "acorn": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", - "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==" }, "ajv": { "version": "6.10.2", @@ -5530,20 +5164,21 @@ } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "requires": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" } }, "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "requires": { - "fd-slicer": "~1.0.1" + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" } }, "yn": { From 41d1864d02f5779bf19b4c185cc41a08a18cf9a3 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Fri, 22 May 2020 23:45:25 +0200 Subject: [PATCH 67/85] Updated versions in ts-default/jquery and ts docs --- docs/generators/typescript.md | 11 +---------- .../builds/default/.openapi-generator/VERSION | 2 +- .../builds/jquery/.openapi-generator/VERSION | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index b711cadad68c..ed96edc9c4ae 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -9,16 +9,7 @@ sidebar_label: typescript |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| -|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. - -When this flag is set to false: - -- The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document. -- Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. -When this flag is set to true: - -- The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. -Note to developers supporting a language generator in OpenAPITools: to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.| |true| +|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION index b5d898602c2c..d99e7162d01f 100644 --- a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION @@ -1 +1 @@ -4.3.1-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION index b5d898602c2c..d99e7162d01f 100644 --- a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION @@ -1 +1 @@ -4.3.1-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file From dee6ed420ea0c0df1c706abb2156b3bffbfba415 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sat, 23 May 2020 19:01:24 +0200 Subject: [PATCH 68/85] Replaced isSuccessCode with is2xx --- .../openapitools/codegen/CodegenResponse.java | 1 - .../org/openapitools/codegen/DefaultCodegen.java | 1 - .../languages/TypeScriptClientCodegen.java | 2 +- .../main/resources/typescript/api/api.mustache | 16 ++++++++-------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java index a7880f49618b..9e9d28958af3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java @@ -28,7 +28,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties { public boolean is4xx; public boolean is5xx; public String message; - public boolean isSuccessCode; public boolean hasMore; public List> examples; public String dataType; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 0123a541d108..c2cd91fc9b67 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3800,7 +3800,6 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { default: throw new RuntimeException("Invalid response code " + responseCode); } - r.isSuccessCode = r.code.startsWith("2"); } Schema responseSchema; if (this.openAPI != null && this.openAPI.getComponents() != null) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 38a3e7502a20..e58429a589fb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -318,7 +318,7 @@ private String getReturnType(List responses) { boolean addVoid = false; for (CodegenResponse response: responses) { // TODO: we should probably catch an exception here - if (response.isSuccessCode) { + if (response.is2xx) { if (response.dataType != null) { if (!firstReturnType) { returnType.append(" | "); diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 8e4b6d52a531..d61c0396d97b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -166,20 +166,20 @@ export class {{classname}}ResponseProcessor { "{{{dataType}}}", "{{returnFormat}}" ) as {{{dataType}}}; {{/isBinary}} - {{#isSuccessCode}} + {{#is2xx}} return body; - {{/isSuccessCode}} - {{^isSuccessCode}} + {{/is2xx}} + {{^is2xx}} throw new ApiException<{{{dataType}}}>({{code}}, body); - {{/isSuccessCode}} + {{/is2xx}} {{/dataType}} {{^dataType}} - {{#isSuccessCode}} + {{#is2xx}} return; - {{/isSuccessCode}} - {{^isSuccessCode}} + {{/is2xx}} + {{^is2xx}} throw new ApiException(response.httpStatusCode, "{{message}}"); - {{/isSuccessCode}} + {{/is2xx}} {{/dataType}} } {{/responses}} From 33c8d19564e4d45d13ef3a7c5af534f793caab6b Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 25 May 2020 22:10:44 +0200 Subject: [PATCH 69/85] [TypeScript-Refactor] Use OAIv3 spec and fix bugs in JQuery Blob download (#6416) * Change to OAIv3 spec for TS-Refactor * Moved samples to oaiv3 folder * Updated package-lock * Update pom to use OAIv3 paths for Typescript-refactor * Renamed ts-refactor samples & tests in pom.xmls * Fixed compile issues in ts-refactor jquery http test * Fixed bugs in blob handling of jquery --- bin/typescript.sh | 4 +- .../resources/typescript/http/jquery.mustache | 15 ++- pom.xml | 20 +++- .../typescript/tests/package-lock.json | 3 - .../typescript/builds/default/.gitignore | 0 .../builds/default/.openapi-generator-ignore | 0 .../builds/default/.openapi-generator/VERSION | 0 .../typescript/builds/default/README.md | 0 .../typescript/builds/default/apis/PetApi.ts | 54 ++++++--- .../builds/default/apis/StoreApi.ts | 16 +-- .../typescript/builds/default/apis/UserApi.ts | 94 +++++++++++----- .../typescript/builds/default/apis/baseapi.ts | 0 .../builds/default/apis/exception.ts | 0 .../typescript/builds/default/auth/auth.ts | 0 .../builds/default/configuration.ts | 0 .../typescript/builds/default/git_push.sh | 0 .../typescript/builds/default/http/http.ts | 0 .../builds/default/http/isomorphic-fetch.ts | 0 .../typescript/builds/default/index.ts | 0 .../typescript/builds/default/middleware.ts | 0 .../builds/default/models/ApiResponse.ts | 0 .../builds/default/models/Category.ts | 0 .../builds/default/models/InlineObject.ts | 48 ++++++++ .../builds/default/models/InlineObject1.ts | 48 ++++++++ .../default}/models/ObjectSerializer.ts | 6 + .../typescript/builds/default/models/Order.ts | 0 .../typescript/builds/default/models/Pet.ts | 0 .../typescript/builds/default/models/Tag.ts | 0 .../typescript/builds/default/models/User.ts | 0 .../typescript/builds/default/models/all.ts | 2 + .../builds/default/package-lock.json | 0 .../typescript/builds/default/package.json | 0 .../typescript/builds/default}/pom.xml | 2 +- .../typescript/builds/default/rxjsStub.ts | 0 .../typescript/builds/default/servers.ts | 0 .../typescript/builds/default/tsconfig.json | 0 .../builds/default/types/ObservableAPI.ts | 44 ++++---- .../builds/default/types/PromiseAPI.ts | 44 ++++---- .../typescript/builds/default/util.ts | 0 .../typescript/builds/jquery/.gitignore | 0 .../builds/jquery/.openapi-generator-ignore | 0 .../builds/jquery/.openapi-generator/VERSION | 0 .../typescript/builds/jquery/README.md | 0 .../petstore/typescript/builds/jquery/TODO.md | 0 .../typescript/builds/jquery/apis/PetApi.ts | 54 ++++++--- .../typescript/builds/jquery/apis/StoreApi.ts | 16 +-- .../typescript/builds/jquery/apis/UserApi.ts | 94 +++++++++++----- .../typescript/builds/jquery/apis/baseapi.ts | 0 .../builds/jquery/apis/exception.ts | 0 .../typescript/builds/jquery/auth/auth.ts | 0 .../typescript/builds/jquery/configuration.ts | 0 .../typescript/builds/jquery/git_push.sh | 0 .../typescript/builds/jquery/http/http.ts | 0 .../typescript/builds/jquery/http/jquery.ts | 15 ++- .../typescript/builds/jquery/index.ts | 0 .../typescript/builds/jquery/middleware.ts | 0 .../builds/jquery/models/ApiResponse.ts | 0 .../builds/jquery/models/Category.ts | 0 .../builds/jquery/models/InlineObject.ts | 48 ++++++++ .../builds/jquery/models/InlineObject1.ts | 48 ++++++++ .../builds/jquery}/models/ObjectSerializer.ts | 6 + .../typescript/builds/jquery/models/Order.ts | 0 .../typescript/builds/jquery/models/Pet.ts | 0 .../typescript/builds/jquery/models/Tag.ts | 0 .../typescript/builds/jquery/models/User.ts | 0 .../typescript/builds/jquery/models/all.ts | 2 + .../builds/jquery/package-lock.json | 0 .../typescript/builds/jquery/package.json | 0 .../typescript/builds/jquery}/pom.xml | 2 +- .../typescript/builds/jquery/rxjsStub.ts | 0 .../typescript/builds/jquery/servers.ts | 0 .../typescript/builds/jquery/tsconfig.json | 0 .../builds/jquery/types/ObservableAPI.ts | 44 ++++---- .../builds/jquery/types/PromiseAPI.ts | 44 ++++---- .../petstore/typescript/builds/jquery/util.ts | 0 .../typescript/tests/default/.gitignore | 0 .../tests/default/package-lock.json | 71 ++++++------ .../typescript/tests/default/package.json | 0 .../petstore/typescript/tests/default/pom.xml | 2 +- .../tests/default/test/api/PetApi.test.ts | 0 .../typescript/tests/default/test/api/pet.png | Bin .../tests/default/test/auth/auth.test.ts | 0 .../test/http/isomorphic-fetch.test.ts | 0 .../test/models/ObjectSerializer.test.ts | 0 .../typescript/tests/default/tsconfig.json | 0 .../typescript/tests/jquery/.gitignore | 0 .../typescript/tests/jquery/index.html | 0 .../tests/jquery/node-qunit-puppeteer.d.ts | 0 .../typescript/tests/jquery/package-lock.json | 104 ++++++------------ .../typescript/tests/jquery/package.json | 0 .../petstore/typescript/tests/jquery/pom.xml | 2 +- .../typescript/tests/jquery/require1k.min.js | 0 .../typescript/tests/jquery/test-runner.ts | 0 .../tests/jquery/test/api/PetApi.test.ts | 0 .../typescript/tests/jquery/test/api/pet.png | Bin .../tests/jquery/test/http/jquery.test.ts | 12 +- .../petstore/typescript/tests/jquery/tests.ts | 0 .../typescript/tests/jquery/tsconfig.json | 0 .../typescript/tests/jquery/webpack.config.js | 0 99 files changed, 643 insertions(+), 321 deletions(-) delete mode 100644 samples/client/petstore/typescript/tests/package-lock.json rename samples/{ => openapi3}/client/petstore/typescript/builds/default/.gitignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/.openapi-generator-ignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/.openapi-generator/VERSION (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/README.md (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/apis/PetApi.ts (91%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/apis/StoreApi.ts (95%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/apis/UserApi.ts (87%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/apis/baseapi.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/apis/exception.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/auth/auth.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/configuration.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/git_push.sh (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/http/http.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/index.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/middleware.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/ApiResponse.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/Category.ts (100%) create mode 100644 samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject1.ts rename samples/{client/petstore/typescript/builds/jquery => openapi3/client/petstore/typescript/builds/default}/models/ObjectSerializer.ts (97%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/Order.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/Pet.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/Tag.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/User.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/models/all.ts (70%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/package-lock.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/package.json (100%) rename samples/{client/petstore/typescript/builds/jquery => openapi3/client/petstore/typescript/builds/default}/pom.xml (96%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/rxjsStub.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/servers.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/tsconfig.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/types/ObservableAPI.ts (94%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/types/PromiseAPI.ts (84%) rename samples/{ => openapi3}/client/petstore/typescript/builds/default/util.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/.gitignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/.openapi-generator-ignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/README.md (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/TODO.md (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/apis/PetApi.ts (91%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/apis/StoreApi.ts (95%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/apis/UserApi.ts (87%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/apis/baseapi.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/apis/exception.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/auth/auth.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/configuration.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/git_push.sh (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/http/http.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/http/jquery.ts (88%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/index.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/middleware.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/ApiResponse.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/Category.ts (100%) create mode 100644 samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject1.ts rename samples/{client/petstore/typescript/builds/default => openapi3/client/petstore/typescript/builds/jquery}/models/ObjectSerializer.ts (97%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/Order.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/Pet.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/Tag.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/User.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/models/all.ts (70%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/package-lock.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/package.json (100%) rename samples/{client/petstore/typescript/builds/default => openapi3/client/petstore/typescript/builds/jquery}/pom.xml (96%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/rxjsStub.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/servers.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/tsconfig.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts (94%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts (84%) rename samples/{ => openapi3}/client/petstore/typescript/builds/jquery/util.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/.gitignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/package-lock.json (94%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/package.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/pom.xml (97%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/test/api/PetApi.test.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/test/api/pet.png (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/test/auth/auth.test.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/default/tsconfig.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/.gitignore (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/index.html (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/package-lock.json (96%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/package.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/pom.xml (97%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/require1k.min.js (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/test-runner.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/test/api/pet.png (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts (91%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/tests.ts (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/tsconfig.json (100%) rename samples/{ => openapi3}/client/petstore/typescript/tests/jquery/webpack.config.js (100%) diff --git a/bin/typescript.sh b/bin/typescript.sh index a94b40df1140..38846529cf7e 100755 --- a/bin/typescript.sh +++ b/bin/typescript.sh @@ -28,10 +28,10 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" echo "Creating default (fetch) client!" -ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default --additional-properties=platform=node,npmName=ts-petstore-client $@" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/default --additional-properties=platform=node,npmName=ts-petstore-client $@" java $JAVA_OPTS -jar $executable $ags echo "Creating jquery client!" -ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index d6a25d993ec2..3c67c5bd6f18 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -21,14 +21,12 @@ export class JQueryHttpLibrary implements HttpLibrary { data: body }; - /** - * Allow receiving binary data with jquery ajax - * - * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ - */ - requestOptions.beforeSend = (jqXHR: any, settings: any) => { - settings.xhr().responseType = "blob"; - }; + // If we want a blob, we have to set the xhrFields' responseType AND add a + // custom converter to overwrite the default deserialization of JQuery... + requestOptions["xhrFields"] = { responseType: 'blob' }; + requestOptions["converters"] = {} + requestOptions["converters"]["* blob"] = (result:any) => result; + requestOptions["dataType"] = "blob"; if (request.getHeaders()['Content-Type']) { @@ -51,6 +49,7 @@ export class JQueryHttpLibrary implements HttpLibrary { if (body && body.constructor.name == "FormData") { requestOptions.contentType = false; } + const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { diff --git a/pom.xml b/pom.xml index 04bf662ac847..eb1ccb213f1b 100644 --- a/pom.xml +++ b/pom.xml @@ -1000,7 +1000,19 @@ - samples/client/petstore/typescript/tests/default + samples/openapi3/client/petstore/typescript/tests/default + + + + typescript-client-tests-jquery + + + env + java + + + + samples/openapi3/client/petstore/typescript/tests/jquery @@ -1271,8 +1283,10 @@ samples/client/petstore/python-tornado samples/openapi3/client/petstore/python samples/openapi3/client/petstore/python-experimental - samples/client/petstore/typescript/builds/default - samples/client/petstore/typescript/tests/default + samples/openapi3/client/petstore/typescript/builds/default + samples/openapi3/client/petstore/typescript/tests/default + samples/openapi3/client/petstore/typescript/builds/jquery + samples/openapi3/client/petstore/typescript/tests/jquery samples/client/petstore/typescript-fetch/builds/default samples/client/petstore/typescript-fetch/builds/es6-target samples/client/petstore/typescript-fetch/builds/with-npm-version diff --git a/samples/client/petstore/typescript/tests/package-lock.json b/samples/client/petstore/typescript/tests/package-lock.json deleted file mode 100644 index 48e341a0954d..000000000000 --- a/samples/client/petstore/typescript/tests/package-lock.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "lockfileVersion": 1 -} diff --git a/samples/client/petstore/typescript/builds/default/.gitignore b/samples/openapi3/client/petstore/typescript/builds/default/.gitignore similarity index 100% rename from samples/client/petstore/typescript/builds/default/.gitignore rename to samples/openapi3/client/petstore/typescript/builds/default/.gitignore diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator-ignore b/samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/typescript/builds/default/.openapi-generator-ignore rename to samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator-ignore diff --git a/samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION b/samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/typescript/builds/default/.openapi-generator/VERSION rename to samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/VERSION diff --git a/samples/client/petstore/typescript/builds/default/README.md b/samples/openapi3/client/petstore/typescript/builds/default/README.md similarity index 100% rename from samples/client/petstore/typescript/builds/default/README.md rename to samples/openapi3/client/petstore/typescript/builds/default/README.md diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts similarity index 91% rename from samples/client/petstore/typescript/builds/default/apis/PetApi.ts rename to samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts index f86ca7a612e7..b512a2cc1847 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -17,14 +17,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): RequestContext { + public addPet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling addPet.'); + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); } @@ -50,7 +50,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Pet", ""), + ObjectSerializer.serialize(pet, "Pet", ""), contentType ); requestContext.setBody(serializedBody); @@ -237,14 +237,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): RequestContext { + public updatePet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling updatePet.'); + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); } @@ -270,7 +270,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Pet", ""), + ObjectSerializer.serialize(pet, "Pet", ""), contentType ); requestContext.setBody(serializedBody); @@ -406,15 +406,26 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public async addPet(response: ResponseContext): Promise< void> { + public async addPet(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } let body = response.body || ""; @@ -552,8 +563,15 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public async updatePet(response: ResponseContext): Promise< void> { + public async updatePet(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -566,7 +584,11 @@ export class PetApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } let body = response.body || ""; diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts similarity index 95% rename from samples/client/petstore/typescript/builds/default/apis/StoreApi.ts rename to samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts index 6e92f2ac33f7..e85458ba3d6c 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -121,14 +121,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): RequestContext { + public placeOrder(order: Order, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling placeOrder.'); + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); } @@ -147,10 +147,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Order", ""), + ObjectSerializer.serialize(order, "Order", ""), contentType ); requestContext.setBody(serializedBody); diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts similarity index 87% rename from samples/client/petstore/typescript/builds/default/apis/UserApi.ts rename to samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts index efce92585dcb..bf6006eb62cb 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -17,14 +17,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): RequestContext { + public createUser(user: User, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUser.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); } @@ -43,29 +43,36 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "User", ""), + ObjectSerializer.serialize(user, "User", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): RequestContext { + public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); } @@ -84,29 +91,36 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Array", ""), + ObjectSerializer.serialize(user, "Array", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): RequestContext { + public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithListInput.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); } @@ -125,15 +139,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Array", ""), + ObjectSerializer.serialize(user, "Array", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -169,7 +190,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -278,7 +304,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -287,9 +318,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): RequestContext { + public updateUser(username: string, user: User, options?: Configuration): RequestContext { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -298,9 +329,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { } - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling updateUser.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); } @@ -320,15 +351,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "User", ""), + ObjectSerializer.serialize(user, "User", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } diff --git a/samples/client/petstore/typescript/builds/default/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/baseapi.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/apis/baseapi.ts rename to samples/openapi3/client/petstore/typescript/builds/default/apis/baseapi.ts diff --git a/samples/client/petstore/typescript/builds/default/apis/exception.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/exception.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/apis/exception.ts rename to samples/openapi3/client/petstore/typescript/builds/default/apis/exception.ts diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/auth/auth.ts rename to samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/default/configuration.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/configuration.ts rename to samples/openapi3/client/petstore/typescript/builds/default/configuration.ts diff --git a/samples/client/petstore/typescript/builds/default/git_push.sh b/samples/openapi3/client/petstore/typescript/builds/default/git_push.sh similarity index 100% rename from samples/client/petstore/typescript/builds/default/git_push.sh rename to samples/openapi3/client/petstore/typescript/builds/default/git_push.sh diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/default/http/http.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/http/http.ts rename to samples/openapi3/client/petstore/typescript/builds/default/http/http.ts diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/openapi3/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts rename to samples/openapi3/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/openapi3/client/petstore/typescript/builds/default/index.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/index.ts rename to samples/openapi3/client/petstore/typescript/builds/default/index.ts diff --git a/samples/client/petstore/typescript/builds/default/middleware.ts b/samples/openapi3/client/petstore/typescript/builds/default/middleware.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/middleware.ts rename to samples/openapi3/client/petstore/typescript/builds/default/middleware.ts diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/ApiResponse.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/Category.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject.ts new file mode 100644 index 000000000000..54192c1c8356 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject { + /** + * Updated name of the pet + */ + 'name'?: string; + /** + * Updated status of the pet + */ + 'status'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return InlineObject.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject1.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject1.ts new file mode 100644 index 000000000000..02e988674a08 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/InlineObject1.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject1 { + /** + * Additional data to pass to server + */ + 'additionalMetadata'?: string; + /** + * file to upload + */ + 'file'?: HttpFile; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "additionalMetadata", + "baseName": "additionalMetadata", + "type": "string", + "format": "" + }, + { + "name": "file", + "baseName": "file", + "type": "HttpFile", + "format": "binary" + } ]; + + static getAttributeTypeMap() { + return InlineObject1.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts similarity index 97% rename from samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index 6eef999baaa3..f485b39e42b3 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -1,5 +1,7 @@ export * from './ApiResponse'; export * from './Category'; +export * from './InlineObject'; +export * from './InlineObject1'; export * from './Order'; export * from './Pet'; export * from './Tag'; @@ -7,6 +9,8 @@ export * from './User'; import { ApiResponse } from './ApiResponse'; import { Category } from './Category'; +import { InlineObject } from './InlineObject'; +import { InlineObject1 } from './InlineObject1'; import { Order , OrderStatusEnum } from './Order'; import { Pet , PetStatusEnum } from './Pet'; import { Tag } from './Tag'; @@ -38,6 +42,8 @@ let enumsMap: Set = new Set([ let typeMap: {[index: string]: any} = { "ApiResponse": ApiResponse, "Category": Category, + "InlineObject": InlineObject, + "InlineObject1": InlineObject1, "Order": Order, "Pet": Pet, "Tag": Tag, diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/Order.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/Pet.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/Tag.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/models/User.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/User.ts diff --git a/samples/client/petstore/typescript/builds/default/models/all.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/all.ts similarity index 70% rename from samples/client/petstore/typescript/builds/default/models/all.ts rename to samples/openapi3/client/petstore/typescript/builds/default/models/all.ts index 2edba7f0bd56..d064eba93abd 100644 --- a/samples/client/petstore/typescript/builds/default/models/all.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/all.ts @@ -1,5 +1,7 @@ export * from './ApiResponse' export * from './Category' +export * from './InlineObject' +export * from './InlineObject1' export * from './Order' export * from './Pet' export * from './Tag' diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/default/package-lock.json similarity index 100% rename from samples/client/petstore/typescript/builds/default/package-lock.json rename to samples/openapi3/client/petstore/typescript/builds/default/package-lock.json diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/openapi3/client/petstore/typescript/builds/default/package.json similarity index 100% rename from samples/client/petstore/typescript/builds/default/package.json rename to samples/openapi3/client/petstore/typescript/builds/default/package.json diff --git a/samples/client/petstore/typescript/builds/jquery/pom.xml b/samples/openapi3/client/petstore/typescript/builds/default/pom.xml similarity index 96% rename from samples/client/petstore/typescript/builds/jquery/pom.xml rename to samples/openapi3/client/petstore/typescript/builds/default/pom.xml index ad8b1d386fcc..c3b2ac33026a 100644 --- a/samples/client/petstore/typescript/builds/jquery/pom.xml +++ b/samples/openapi3/client/petstore/typescript/builds/default/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptBuildPetstoreClientSample + TypeScriptBuildDefaultPetstoreClientSample pom 1.0-SNAPSHOT TS Default Petstore Client diff --git a/samples/client/petstore/typescript/builds/default/rxjsStub.ts b/samples/openapi3/client/petstore/typescript/builds/default/rxjsStub.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/rxjsStub.ts rename to samples/openapi3/client/petstore/typescript/builds/default/rxjsStub.ts diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/openapi3/client/petstore/typescript/builds/default/servers.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/servers.ts rename to samples/openapi3/client/petstore/typescript/builds/default/servers.ts diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json similarity index 100% rename from samples/client/petstore/typescript/builds/default/tsconfig.json rename to samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json diff --git a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts similarity index 94% rename from samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts rename to samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 1c31558e9b21..cdc77b530a78 100644 --- a/samples/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -6,6 +6,8 @@ import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; import { Tag } from '../models/Tag'; @@ -25,10 +27,10 @@ export class ObservablePetApi { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(body, options); + public addPet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.addPet(pet, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -144,10 +146,10 @@ export class ObservablePetApi { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(body, options); + public updatePet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePet(pet, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -306,10 +308,10 @@ export class ObservableStoreApi { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(body, options); + public placeOrder(order: Order, options?: Configuration): Observable { + const requestContext = this.requestFactory.placeOrder(order, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -348,10 +350,10 @@ export class ObservableUserApi { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(body, options); + public createUser(user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUser(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -371,10 +373,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(body, options); + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -394,10 +396,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(body, options); + public createUsersWithListInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithListInput(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -512,10 +514,10 @@ export class ObservableUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, body, options); + public updateUser(username: string, user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.updateUser(username, user, options); // build promise chain let middlewarePreObservable = of(requestContext); diff --git a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts similarity index 84% rename from samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts rename to samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts index 9aabd2472684..159708737069 100644 --- a/samples/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -4,6 +4,8 @@ import { Configuration} from '../configuration' import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; import { Tag } from '../models/Tag'; @@ -21,10 +23,10 @@ export class PromisePetApi { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): Promise { - const result = this.api.addPet(body, options); + public addPet(pet: Pet, options?: Configuration): Promise { + const result = this.api.addPet(pet, options); return result.toPromise(); } @@ -70,10 +72,10 @@ export class PromisePetApi { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): Promise { - const result = this.api.updatePet(body, options); + public updatePet(pet: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(pet, options); return result.toPromise(); } @@ -146,10 +148,10 @@ export class PromiseStoreApi { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): Promise { - const result = this.api.placeOrder(body, options); + public placeOrder(order: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(order, options); return result.toPromise(); } @@ -172,28 +174,28 @@ export class PromiseUserApi { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): Promise { - const result = this.api.createUser(body, options); + public createUser(user: User, options?: Configuration): Promise { + const result = this.api.createUser(user, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithArrayInput(body, options); + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(user, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithListInput(body, options); + public createUsersWithListInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(user, options); return result.toPromise(); } @@ -238,10 +240,10 @@ export class PromiseUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): Promise { - const result = this.api.updateUser(username, body, options); + public updateUser(username: string, user: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, user, options); return result.toPromise(); } diff --git a/samples/client/petstore/typescript/builds/default/util.ts b/samples/openapi3/client/petstore/typescript/builds/default/util.ts similarity index 100% rename from samples/client/petstore/typescript/builds/default/util.ts rename to samples/openapi3/client/petstore/typescript/builds/default/util.ts diff --git a/samples/client/petstore/typescript/builds/jquery/.gitignore b/samples/openapi3/client/petstore/typescript/builds/jquery/.gitignore similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/.gitignore rename to samples/openapi3/client/petstore/typescript/builds/jquery/.gitignore diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore b/samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/.openapi-generator-ignore rename to samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator-ignore diff --git a/samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION b/samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION rename to samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/VERSION diff --git a/samples/client/petstore/typescript/builds/jquery/README.md b/samples/openapi3/client/petstore/typescript/builds/jquery/README.md similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/README.md rename to samples/openapi3/client/petstore/typescript/builds/jquery/README.md diff --git a/samples/client/petstore/typescript/builds/jquery/TODO.md b/samples/openapi3/client/petstore/typescript/builds/jquery/TODO.md similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/TODO.md rename to samples/openapi3/client/petstore/typescript/builds/jquery/TODO.md diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts similarity index 91% rename from samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts index 6fec1ad3d232..68e401b36df0 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -16,14 +16,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): RequestContext { + public addPet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling addPet.'); + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); } @@ -49,7 +49,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Pet", ""), + ObjectSerializer.serialize(pet, "Pet", ""), contentType ); requestContext.setBody(serializedBody); @@ -236,14 +236,14 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): RequestContext { + public updatePet(pet: Pet, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling updatePet.'); + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); } @@ -269,7 +269,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Pet", ""), + ObjectSerializer.serialize(pet, "Pet", ""), contentType ); requestContext.setBody(serializedBody); @@ -405,15 +405,26 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public async addPet(response: ResponseContext): Promise< void> { + public async addPet(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } let body = response.body || ""; @@ -551,8 +562,15 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public async updatePet(response: ResponseContext): Promise< void> { + public async updatePet(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -565,7 +583,11 @@ export class PetApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } let body = response.body || ""; diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts similarity index 95% rename from samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index c7cca9dc1d89..15b86c2bcf02 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -120,14 +120,14 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): RequestContext { + public placeOrder(order: Order, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling placeOrder.'); + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); } @@ -146,10 +146,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Order", ""), + ObjectSerializer.serialize(order, "Order", ""), contentType ); requestContext.setBody(serializedBody); diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts similarity index 87% rename from samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts index 46222492ed85..ab56faf47700 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -16,14 +16,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): RequestContext { + public createUser(user: User, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUser.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); } @@ -42,29 +42,36 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "User", ""), + ObjectSerializer.serialize(user, "User", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): RequestContext { + public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); } @@ -83,29 +90,36 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Array", ""), + ObjectSerializer.serialize(user, "Array", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): RequestContext { + public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { let config = options || this.configuration; - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling createUsersWithListInput.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); } @@ -124,15 +138,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "Array", ""), + ObjectSerializer.serialize(user, "Array", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -168,7 +189,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -277,7 +303,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } @@ -286,9 +317,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): RequestContext { + public updateUser(username: string, user: User, options?: Configuration): RequestContext { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -297,9 +328,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { } - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError('Required parameter body was null or undefined when calling updateUser.'); + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); } @@ -319,15 +350,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([]); + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "User", ""), + ObjectSerializer.serialize(user, "User", ""), contentType ); requestContext.setBody(serializedBody); + let authMethod = null; // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } return requestContext; } diff --git a/samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/baseapi.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/apis/baseapi.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/apis/baseapi.ts diff --git a/samples/client/petstore/typescript/builds/jquery/apis/exception.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/exception.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/apis/exception.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/apis/exception.ts diff --git a/samples/client/petstore/typescript/builds/jquery/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/auth/auth.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts diff --git a/samples/client/petstore/typescript/builds/jquery/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/configuration.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts diff --git a/samples/client/petstore/typescript/builds/jquery/git_push.sh b/samples/openapi3/client/petstore/typescript/builds/jquery/git_push.sh similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/git_push.sh rename to samples/openapi3/client/petstore/typescript/builds/jquery/git_push.sh diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/http/http.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/http/jquery.ts similarity index 88% rename from samples/client/petstore/typescript/builds/jquery/http/jquery.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/http/jquery.ts index 238eef3be089..a0cd53a1996c 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -21,14 +21,12 @@ export class JQueryHttpLibrary implements HttpLibrary { data: body }; - /** - * Allow receiving binary data with jquery ajax - * - * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ - */ - requestOptions.beforeSend = (jqXHR: any, settings: any) => { - settings.xhr().responseType = "blob"; - }; + // If we want a blob, we have to set the xhrFields' responseType AND add a + // custom converter to overwrite the default deserialization of JQuery... + requestOptions["xhrFields"] = { responseType: 'blob' }; + requestOptions["converters"] = {} + requestOptions["converters"]["* blob"] = (result:any) => result; + requestOptions["dataType"] = "blob"; if (request.getHeaders()['Content-Type']) { @@ -51,6 +49,7 @@ export class JQueryHttpLibrary implements HttpLibrary { if (body && body.constructor.name == "FormData") { requestOptions.contentType = false; } + const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/index.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/index.ts diff --git a/samples/client/petstore/typescript/builds/jquery/middleware.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/middleware.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/middleware.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/middleware.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/ApiResponse.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/Category.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject.ts new file mode 100644 index 000000000000..54192c1c8356 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject { + /** + * Updated name of the pet + */ + 'name'?: string; + /** + * Updated status of the pet + */ + 'status'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return InlineObject.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject1.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject1.ts new file mode 100644 index 000000000000..02e988674a08 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/InlineObject1.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject1 { + /** + * Additional data to pass to server + */ + 'additionalMetadata'?: string; + /** + * file to upload + */ + 'file'?: HttpFile; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "additionalMetadata", + "baseName": "additionalMetadata", + "type": "string", + "format": "" + }, + { + "name": "file", + "baseName": "file", + "type": "HttpFile", + "format": "binary" + } ]; + + static getAttributeTypeMap() { + return InlineObject1.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts similarity index 97% rename from samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index 6eef999baaa3..f485b39e42b3 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -1,5 +1,7 @@ export * from './ApiResponse'; export * from './Category'; +export * from './InlineObject'; +export * from './InlineObject1'; export * from './Order'; export * from './Pet'; export * from './Tag'; @@ -7,6 +9,8 @@ export * from './User'; import { ApiResponse } from './ApiResponse'; import { Category } from './Category'; +import { InlineObject } from './InlineObject'; +import { InlineObject1 } from './InlineObject1'; import { Order , OrderStatusEnum } from './Order'; import { Pet , PetStatusEnum } from './Pet'; import { Tag } from './Tag'; @@ -38,6 +42,8 @@ let enumsMap: Set = new Set([ let typeMap: {[index: string]: any} = { "ApiResponse": ApiResponse, "Category": Category, + "InlineObject": InlineObject, + "InlineObject1": InlineObject1, "Order": Order, "Pet": Pet, "Tag": Tag, diff --git a/samples/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/Order.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/Pet.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/Tag.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/models/User.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts diff --git a/samples/client/petstore/typescript/builds/jquery/models/all.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/all.ts similarity index 70% rename from samples/client/petstore/typescript/builds/jquery/models/all.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/models/all.ts index 2edba7f0bd56..d064eba93abd 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/all.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/all.ts @@ -1,5 +1,7 @@ export * from './ApiResponse' export * from './Category' +export * from './InlineObject' +export * from './InlineObject1' export * from './Order' export * from './Pet' export * from './Tag' diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/package-lock.json rename to samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json diff --git a/samples/client/petstore/typescript/builds/jquery/package.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package.json similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/package.json rename to samples/openapi3/client/petstore/typescript/builds/jquery/package.json diff --git a/samples/client/petstore/typescript/builds/default/pom.xml b/samples/openapi3/client/petstore/typescript/builds/jquery/pom.xml similarity index 96% rename from samples/client/petstore/typescript/builds/default/pom.xml rename to samples/openapi3/client/petstore/typescript/builds/jquery/pom.xml index ad8b1d386fcc..9bd07b654f72 100644 --- a/samples/client/petstore/typescript/builds/default/pom.xml +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptBuildPetstoreClientSample + TypeScriptBuildJQueryPetstoreClientSample pom 1.0-SNAPSHOT TS Default Petstore Client diff --git a/samples/client/petstore/typescript/builds/jquery/rxjsStub.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/rxjsStub.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/rxjsStub.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/rxjsStub.ts diff --git a/samples/client/petstore/typescript/builds/jquery/servers.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/servers.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts diff --git a/samples/client/petstore/typescript/builds/jquery/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/tsconfig.json rename to samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json diff --git a/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts similarity index 94% rename from samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts index 1c31558e9b21..cdc77b530a78 100644 --- a/samples/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts @@ -6,6 +6,8 @@ import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; import { Tag } from '../models/Tag'; @@ -25,10 +27,10 @@ export class ObservablePetApi { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(body, options); + public addPet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.addPet(pet, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -144,10 +146,10 @@ export class ObservablePetApi { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(body, options); + public updatePet(pet: Pet, options?: Configuration): Observable { + const requestContext = this.requestFactory.updatePet(pet, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -306,10 +308,10 @@ export class ObservableStoreApi { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(body, options); + public placeOrder(order: Order, options?: Configuration): Observable { + const requestContext = this.requestFactory.placeOrder(order, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -348,10 +350,10 @@ export class ObservableUserApi { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(body, options); + public createUser(user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUser(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -371,10 +373,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(body, options); + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -394,10 +396,10 @@ export class ObservableUserApi { /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(body, options); + public createUsersWithListInput(user: Array, options?: Configuration): Observable { + const requestContext = this.requestFactory.createUsersWithListInput(user, options); // build promise chain let middlewarePreObservable = of(requestContext); @@ -512,10 +514,10 @@ export class ObservableUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, body, options); + public updateUser(username: string, user: User, options?: Configuration): Observable { + const requestContext = this.requestFactory.updateUser(username, user, options); // build promise chain let middlewarePreObservable = of(requestContext); diff --git a/samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts similarity index 84% rename from samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts index 9aabd2472684..159708737069 100644 --- a/samples/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts @@ -4,6 +4,8 @@ import { Configuration} from '../configuration' import { ApiResponse } from '../models/ApiResponse'; import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; import { Order } from '../models/Order'; import { Pet } from '../models/Pet'; import { Tag } from '../models/Tag'; @@ -21,10 +23,10 @@ export class PromisePetApi { /** * Add a new pet to the store - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public addPet(body: Pet, options?: Configuration): Promise { - const result = this.api.addPet(body, options); + public addPet(pet: Pet, options?: Configuration): Promise { + const result = this.api.addPet(pet, options); return result.toPromise(); } @@ -70,10 +72,10 @@ export class PromisePetApi { /** * Update an existing pet - * @param body Pet object that needs to be added to the store + * @param pet Pet object that needs to be added to the store */ - public updatePet(body: Pet, options?: Configuration): Promise { - const result = this.api.updatePet(body, options); + public updatePet(pet: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(pet, options); return result.toPromise(); } @@ -146,10 +148,10 @@ export class PromiseStoreApi { /** * Place an order for a pet - * @param body order placed for purchasing the pet + * @param order order placed for purchasing the pet */ - public placeOrder(body: Order, options?: Configuration): Promise { - const result = this.api.placeOrder(body, options); + public placeOrder(order: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(order, options); return result.toPromise(); } @@ -172,28 +174,28 @@ export class PromiseUserApi { /** * This can only be done by the logged in user. * Create user - * @param body Created user object + * @param user Created user object */ - public createUser(body: User, options?: Configuration): Promise { - const result = this.api.createUser(body, options); + public createUser(user: User, options?: Configuration): Promise { + const result = this.api.createUser(user, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithArrayInput(body: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithArrayInput(body, options); + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(user, options); return result.toPromise(); } /** * Creates list of users with given input array - * @param body List of user object + * @param user List of user object */ - public createUsersWithListInput(body: Array, options?: Configuration): Promise { - const result = this.api.createUsersWithListInput(body, options); + public createUsersWithListInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(user, options); return result.toPromise(); } @@ -238,10 +240,10 @@ export class PromiseUserApi { * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted - * @param body Updated user object + * @param user Updated user object */ - public updateUser(username: string, body: User, options?: Configuration): Promise { - const result = this.api.updateUser(username, body, options); + public updateUser(username: string, user: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, user, options); return result.toPromise(); } diff --git a/samples/client/petstore/typescript/builds/jquery/util.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/util.ts similarity index 100% rename from samples/client/petstore/typescript/builds/jquery/util.ts rename to samples/openapi3/client/petstore/typescript/builds/jquery/util.ts diff --git a/samples/client/petstore/typescript/tests/default/.gitignore b/samples/openapi3/client/petstore/typescript/tests/default/.gitignore similarity index 100% rename from samples/client/petstore/typescript/tests/default/.gitignore rename to samples/openapi3/client/petstore/typescript/tests/default/.gitignore diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json similarity index 94% rename from samples/client/petstore/typescript/tests/default/package-lock.json rename to samples/openapi3/client/petstore/typescript/tests/default/package-lock.json index 6bd3eb97155e..60e8e1b6f4bb 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json @@ -1224,6 +1224,7 @@ "version": "file:../../builds/default", "requires": { "@types/node": "*", + "@types/node-fetch": "^2.5.7", "btoa": "^1.2.1", "es6-promise": "^4.2.4", "form-data": "^2.5.0", @@ -1233,46 +1234,57 @@ "dependencies": { "@types/isomorphic-fetch": { "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", - "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" + "bundled": true }, "@types/node": { "version": "12.12.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", - "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" + "bundled": true + }, + "@types/node-fetch": { + "version": "2.5.7", + "bundled": true, + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "bundled": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } }, "asynckit": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "bundled": true }, "btoa": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", - "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + "bundled": true }, "combined-stream": { "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "bundled": true, "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "bundled": true }, "es6-promise": { "version": "4.2.5", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", - "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" + "bundled": true }, "form-data": { "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "bundled": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -1281,49 +1293,41 @@ }, "isomorphic-fetch": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "bundled": true, "requires": { "whatwg-fetch": ">=0.10.0" } }, "mime-db": { "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + "bundled": true }, "mime-types": { "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "bundled": true, "requires": { "mime-db": "1.40.0" } }, "node-fetch": { "version": "2.6.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", - "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + "bundled": true }, "querystringify": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", - "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==" + "bundled": true }, "requires-port": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + "bundled": true }, "typescript": { "version": "2.9.2", - "resolved": false, - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" + "bundled": true }, "url-parse": { "version": "1.4.3", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", - "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", + "bundled": true, "requires": { "querystringify": "^2.0.0", "requires-port": "^1.0.0" @@ -1331,8 +1335,7 @@ }, "whatwg-fetch": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + "bundled": true } } }, diff --git a/samples/client/petstore/typescript/tests/default/package.json b/samples/openapi3/client/petstore/typescript/tests/default/package.json similarity index 100% rename from samples/client/petstore/typescript/tests/default/package.json rename to samples/openapi3/client/petstore/typescript/tests/default/package.json diff --git a/samples/client/petstore/typescript/tests/default/pom.xml b/samples/openapi3/client/petstore/typescript/tests/default/pom.xml similarity index 97% rename from samples/client/petstore/typescript/tests/default/pom.xml rename to samples/openapi3/client/petstore/typescript/tests/default/pom.xml index 6cf652cef1e9..e6135cc7f845 100644 --- a/samples/client/petstore/typescript/tests/default/pom.xml +++ b/samples/openapi3/client/petstore/typescript/tests/default/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptPetstoreClientTests + TypeScriptDefaultPetstoreClientTests pom 1.0-SNAPSHOT TS Petstore Test Client diff --git a/samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts similarity index 100% rename from samples/client/petstore/typescript/tests/default/test/api/PetApi.test.ts rename to samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts diff --git a/samples/client/petstore/typescript/tests/default/test/api/pet.png b/samples/openapi3/client/petstore/typescript/tests/default/test/api/pet.png similarity index 100% rename from samples/client/petstore/typescript/tests/default/test/api/pet.png rename to samples/openapi3/client/petstore/typescript/tests/default/test/api/pet.png diff --git a/samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts similarity index 100% rename from samples/client/petstore/typescript/tests/default/test/auth/auth.test.ts rename to samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts similarity index 100% rename from samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts rename to samples/openapi3/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts similarity index 100% rename from samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts rename to samples/openapi3/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts diff --git a/samples/client/petstore/typescript/tests/default/tsconfig.json b/samples/openapi3/client/petstore/typescript/tests/default/tsconfig.json similarity index 100% rename from samples/client/petstore/typescript/tests/default/tsconfig.json rename to samples/openapi3/client/petstore/typescript/tests/default/tsconfig.json diff --git a/samples/client/petstore/typescript/tests/jquery/.gitignore b/samples/openapi3/client/petstore/typescript/tests/jquery/.gitignore similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/.gitignore rename to samples/openapi3/client/petstore/typescript/tests/jquery/.gitignore diff --git a/samples/client/petstore/typescript/tests/jquery/index.html b/samples/openapi3/client/petstore/typescript/tests/jquery/index.html similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/index.html rename to samples/openapi3/client/petstore/typescript/tests/jquery/index.html diff --git a/samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts rename to samples/openapi3/client/petstore/typescript/tests/jquery/node-qunit-puppeteer.d.ts diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json similarity index 96% rename from samples/client/petstore/typescript/tests/jquery/package-lock.json rename to samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json index b947dee27386..cb57318ae681 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json @@ -2886,8 +2886,7 @@ "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "optional": true + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, "npm-run-path": { "version": "2.0.2", @@ -3145,8 +3144,7 @@ "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "optional": true + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" }, "pify": { "version": "4.0.1", @@ -4294,35 +4292,31 @@ "@types/jquery": "^3.3.29", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "jquery": "^3.5.1", + "jquery": "^3.4.1", "url-parse": "^1.4.3" }, "dependencies": { "@types/form-data": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "bundled": true, "requires": { "@types/node": "*" } }, "@types/jquery": { "version": "3.3.29", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", - "integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==", + "bundled": true, "requires": { "@types/sizzle": "*" } }, "@types/node": { "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", - "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" + "bundled": true }, "@types/rx": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", - "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "bundled": true, "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*", @@ -4340,21 +4334,18 @@ }, "@types/rx-core": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", - "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + "bundled": true }, "@types/rx-core-binding": { "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", - "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "bundled": true, "requires": { "@types/rx-core": "*" } }, "@types/rx-lite": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", - "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", + "bundled": true, "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*" @@ -4362,113 +4353,97 @@ }, "@types/rx-lite-aggregates": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", - "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-async": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", - "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-backpressure": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", - "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-coincidence": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", - "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-experimental": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", - "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-joinpatterns": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", - "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-testing": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", - "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "bundled": true, "requires": { "@types/rx-lite-virtualtime": "*" } }, "@types/rx-lite-time": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", - "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-virtualtime": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", - "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "bundled": true, "requires": { "@types/rx-lite": "*" } }, "@types/sizzle": { "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", - "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" + "bundled": true }, "asynckit": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "bundled": true }, "btoa": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", - "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + "bundled": true }, "combined-stream": { "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "bundled": true, "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "bundled": true }, "es6-promise": { "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + "bundled": true }, "form-data": { "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "bundled": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -4477,54 +4452,45 @@ }, "jquery": { "version": "3.5.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", - "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" + "bundled": true }, "mime-db": { "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + "bundled": true }, "mime-types": { "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "bundled": true, "requires": { "mime-db": "1.40.0" } }, "querystringify": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", - "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + "bundled": true }, "requires-port": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + "bundled": true }, "rxjs": { "version": "6.5.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", - "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", + "bundled": true, "requires": { "tslib": "^1.9.0" } }, "tslib": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + "bundled": true }, "typescript": { "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" + "bundled": true }, "url-parse": { "version": "1.4.7", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", - "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "bundled": true, "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" diff --git a/samples/client/petstore/typescript/tests/jquery/package.json b/samples/openapi3/client/petstore/typescript/tests/jquery/package.json similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/package.json rename to samples/openapi3/client/petstore/typescript/tests/jquery/package.json diff --git a/samples/client/petstore/typescript/tests/jquery/pom.xml b/samples/openapi3/client/petstore/typescript/tests/jquery/pom.xml similarity index 97% rename from samples/client/petstore/typescript/tests/jquery/pom.xml rename to samples/openapi3/client/petstore/typescript/tests/jquery/pom.xml index c8fea0f2c067..13f65131ba92 100644 --- a/samples/client/petstore/typescript/tests/jquery/pom.xml +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - TypeScriptPetstoreClientTests + TypeScriptJQueryPetstoreClientTests pom 1.0-SNAPSHOT TS Petstore Test Client diff --git a/samples/client/petstore/typescript/tests/jquery/require1k.min.js b/samples/openapi3/client/petstore/typescript/tests/jquery/require1k.min.js similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/require1k.min.js rename to samples/openapi3/client/petstore/typescript/tests/jquery/require1k.min.js diff --git a/samples/client/petstore/typescript/tests/jquery/test-runner.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/test-runner.ts similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/test-runner.ts rename to samples/openapi3/client/petstore/typescript/tests/jquery/test-runner.ts diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts rename to samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts diff --git a/samples/client/petstore/typescript/tests/jquery/test/api/pet.png b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/pet.png similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/test/api/pet.png rename to samples/openapi3/client/petstore/typescript/tests/jquery/test/api/pet.png diff --git a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts similarity index 91% rename from samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts rename to samples/openapi3/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts index c8715e14a275..0898ca7f1551 100644 --- a/samples/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/test/http/jquery.test.ts @@ -17,10 +17,12 @@ for (let libName in libs) { return new Promise((resolve, reject) => { lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((txtBody: string) => { + let body = JSON.parse(txtBody); assert.ok(body["headers"]); assert.equal(body["headers"]["X-Test-Token"],"Test-Token"); - resolve() + resolve() }, (e: any) => { console.error(e) @@ -44,12 +46,14 @@ for (let libName in libs) { lib.send(requestContext).toPromise().then( (resp: petstore.ResponseContext) => { assert.ok(resp.httpStatusCode, 200, "Expected status code to be 200"); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((txtBody: any) => { + let body = JSON.parse(txtBody); assert.ok(body["headers"]); assert.equal(body["headers"]["X-Test-Token"], "Test-Token"); assert.equal(body["files"]["testFile"], "abc"); assert.equal(body["form"]["test"], "test2"); - resolve(); + resolve(); }, (e: any) => { console.error(e) diff --git a/samples/client/petstore/typescript/tests/jquery/tests.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/tests.ts similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/tests.ts rename to samples/openapi3/client/petstore/typescript/tests/jquery/tests.ts diff --git a/samples/client/petstore/typescript/tests/jquery/tsconfig.json b/samples/openapi3/client/petstore/typescript/tests/jquery/tsconfig.json similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/tsconfig.json rename to samples/openapi3/client/petstore/typescript/tests/jquery/tsconfig.json diff --git a/samples/client/petstore/typescript/tests/jquery/webpack.config.js b/samples/openapi3/client/petstore/typescript/tests/jquery/webpack.config.js similarity index 100% rename from samples/client/petstore/typescript/tests/jquery/webpack.config.js rename to samples/openapi3/client/petstore/typescript/tests/jquery/webpack.config.js From ae8c1be09d5bb5616fc7f52f824389895860f5d9 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 29 May 2020 22:21:35 +0200 Subject: [PATCH 70/85] [Typescript] Support http bearer authentication with token provider (#6425) * Add http bearer security * Update typescript to 3.9 * Fix: Use Authorization header for basic and bearer * Allow asynchronous tokenProvider in bearer auth --- .../resources/typescript/api/api.mustache | 32 ++-- .../resources/typescript/auth/auth.mustache | 62 ++++-- .../resources/typescript/http/http.mustache | 2 +- .../typescript/http/servers.mustache | 30 ++- .../resources/typescript/package.mustache | 2 +- .../typescript/types/ObservableAPI.mustache | 6 +- .../typescript/builds/default/apis/PetApi.ts | 176 +++++++++--------- .../builds/default/apis/StoreApi.ts | 58 +++--- .../typescript/builds/default/apis/UserApi.ts | 156 ++++++++-------- .../typescript/builds/default/auth/auth.ts | 47 +++-- .../builds/default/package-lock.json | 6 +- .../typescript/builds/default/package.json | 2 +- .../typescript/builds/default/servers.ts | 30 ++- .../builds/default/types/ObservableAPI.ts | 82 ++++---- .../typescript/builds/jquery/apis/PetApi.ts | 176 +++++++++--------- .../typescript/builds/jquery/apis/StoreApi.ts | 58 +++--- .../typescript/builds/jquery/apis/UserApi.ts | 156 ++++++++-------- .../typescript/builds/jquery/auth/auth.ts | 47 +++-- .../typescript/builds/jquery/http/http.ts | 2 +- .../builds/jquery/package-lock.json | 6 +- .../typescript/builds/jquery/package.json | 2 +- .../typescript/builds/jquery/servers.ts | 30 ++- .../builds/jquery/types/ObservableAPI.ts | 82 ++++---- .../tests/default/package-lock.json | 21 +++ 24 files changed, 673 insertions(+), 598 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index d61c0396d97b..17d64ecfd22c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -33,7 +33,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { * @param {{paramName}} {{description}} {{/allParams}} */ - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): RequestContext { + public async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise { let config = options || this.configuration; {{#allParams}} @@ -120,22 +120,22 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { ); requestContext.setBody(serializedBody); {{/bodyParam}} - - {{#hasAuthMethods}} - let authMethod = null; - {{/hasAuthMethods}} - // Apply auth methods - {{#authMethods}} - authMethod = config.authMethods["{{name}}"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - {{/authMethods}} - - return requestContext; + + {{#hasAuthMethods}} + let authMethod = null; + {{/hasAuthMethods}} + // Apply auth methods + {{#authMethods}} + authMethod = config.authMethods["{{name}}"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + {{/authMethods}} + + return requestContext; } - - {{/operation}} + + {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 75374bd2b738..09d927066a04 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -26,7 +26,7 @@ export abstract class SecurityAuthentication { * * @params context the request context which should use this authentication scheme */ - public abstract applySecurityAuthentication(context: RequestContext): void; + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; } @@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication { public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; - context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + context.setHeaderParam("Authorization", "Basic " + btoa(comb)); } } +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies http bearer authentication to a request. + * + */ +export class HttpBearerAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in openapi specification + * @param tokenProvider service that can provide the up-to-date token when needed + */ + public constructor(authName: string, private tokenProvider: TokenProvider) { + super(authName); + } + + public async applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + } +} + // TODO: How to handle oauth2 authentication! export class OAuth2Authentication extends SecurityAuthentication { public constructor(authName: string) { @@ -112,36 +137,39 @@ export class OAuth2Authentication extends SecurityAuthentication { export type AuthMethods = { {{#authMethods}} - "{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isHttp}}HttpBasicAuthentication{{/isHttp}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}}, + "{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isBasicBasic}}HttpBasicAuthentication{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerAuthentication{{/isBasicBearer}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}}, {{/authMethods}} } export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; -export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isHttp}}HttpBasicConfiguration{{/isHttp}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } +export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } /** * Creates the authentication methods from a swagger description. * */ -export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { - let authMethods: AuthMethods = { - } +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} - if (!conf) { - return authMethods; - } + if (!config) { + return authMethods; + } {{#authMethods}} - if (conf["{{name}}"]) { - {{#isApiKey}} - authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, conf["{{name}}"]); - {{/isApiKey}} - {{#isBasic}} - authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]); - {{/isBasic}} + if (config["{{name}}"]) { + {{#isApiKey}} + authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, config["{{name}}"]); + {{/isApiKey}} + {{#isBasicBasic}} + authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]); + {{/isBasicBasic}} + {{#isBasicBearer}} + authMethods["{{name}}"] = new HttpBearerAuthentication("{{name}}", config["{{name}}"]["tokenProvider"]); + {{/isBasicBearer}} {{#isOAuth}} authMethods["{{name}}"] = new OAuth2Authentication("{{name}}"); {{/isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 66bdb2e5c2c1..ec5f6f379f37 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -172,7 +172,7 @@ export class SelfDecodingBody implements ResponseBody { return new Promise((resolve, reject) => { const reader = new FileReader(); - reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("load", () => resolve(reader.result as string)); reader.addEventListener("error", () => reject(reader.error)); reader.readAsText(data); }); diff --git a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache index db4ea7a9dd39..41b5d204ec0e 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache @@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { - - public constructor(private url: string, private variableConfiguration: T) { +export class ServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); } - - /** - * Sets the value of the variables of this server. - * - * @param variableConfiguration a partial variable configuration for the variables contained in the url - */ - public setVariables(variableConfiguration: Partial) { - for (const key in variableConfiguration) { - const val = variableConfiguration[key] - // We know that val isn't undefined here - hopefully - if (val !== undefined) { - this.variableConfiguration[key] = val as T[Extract]; - } - } - } public getConfiguration(): T { return this.variableConfiguration @@ -34,7 +26,7 @@ export class ServerConfiguration { let replacedUrl = this.url; for (const key in this.variableConfiguration) { var re = new RegExp("{" + key + "}","g"); - replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); } return replacedUrl } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 608318ea2dfc..50475a5d4675 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -48,7 +48,7 @@ "url-parse": "^1.4.3" }, "devDependencies": { - "typescript": "^2.9.2" + "typescript": "^3.9.3" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig":{ diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache index 2ce28f0a7735..6590d71aca58 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache @@ -1,7 +1,7 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; +import { Observable, of, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; {{#models}} @@ -38,10 +38,10 @@ export class Observable{{classname}} { {{/allParams}} */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { - const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + const requestContextPromise = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts index b512a2cc1847..7041341a7089 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -19,7 +19,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { * Add a new pet to the store * @param pet Pet object that needs to be added to the store */ - public addPet(pet: Pet, options?: Configuration): RequestContext { + public async addPet(pet: Pet, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'pet' is not null or undefined @@ -54,23 +54,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Deletes a pet * @param petId Pet id to delete * @param apiKey */ - public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext { + public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -97,23 +97,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Multiple status values can be provided with comma separated strings * Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext { + public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'status' is not null or undefined @@ -140,23 +140,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags(tags: Array, options?: Configuration): RequestContext { + public async findPetsByTags(tags: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'tags' is not null or undefined @@ -183,23 +183,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Returns a single pet * Find pet by ID * @param petId ID of pet to return */ - public getPetById(petId: number, options?: Configuration): RequestContext { + public async getPetById(petId: number, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -224,22 +224,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Update an existing pet * @param pet Pet object that needs to be added to the store */ - public updatePet(pet: Pet, options?: Configuration): RequestContext { + public async updatePet(pet: Pet, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'pet' is not null or undefined @@ -274,24 +274,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * 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: number, name?: string, status?: string, options?: Configuration): RequestContext { + public async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -328,24 +328,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setBody(localVarFormParams); // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * uploads an image * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext { + public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -382,17 +382,17 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setBody(localVarFormParams); // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts index e85458ba3d6c..09400e99c083 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -19,7 +19,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { * Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ - public deleteOrder(orderId: string, options?: Configuration): RequestContext { + public async deleteOrder(orderId: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'orderId' is not null or undefined @@ -44,17 +44,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - public getInventory(options?: Configuration): RequestContext { + public async getInventory(options?: Configuration): Promise { let config = options || this.configuration; // Path Params @@ -72,23 +72,23 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: number, options?: Configuration): RequestContext { + public async getOrderById(orderId: number, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'orderId' is not null or undefined @@ -113,17 +113,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Place an order for a pet * @param order order placed for purchasing the pet */ - public placeOrder(order: Order, options?: Configuration): RequestContext { + public async placeOrder(order: Order, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'order' is not null or undefined @@ -156,12 +156,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts index bf6006eb62cb..1d43ec7a72b4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -19,7 +19,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { * Create user * @param user Created user object */ - public createUser(user: User, options?: Configuration): RequestContext { + public async createUser(user: User, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -52,22 +52,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Creates list of users with given input array * @param user List of user object */ - public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { + public async createUsersWithArrayInput(user: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -100,22 +100,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Creates list of users with given input array * @param user List of user object */ - public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { + public async createUsersWithListInput(user: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -148,23 +148,23 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * This can only be done by the logged in user. * Delete user * @param username The name that needs to be deleted */ - public deleteUser(username: string, options?: Configuration): RequestContext { + public async deleteUser(username: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -189,22 +189,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName(username: string, options?: Configuration): RequestContext { + public async getUserByName(username: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -229,18 +229,18 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Logs user into the system * @param username The user name for login * @param password The password for login in clear text */ - public loginUser(username: string, password: string, options?: Configuration): RequestContext { + public async loginUser(username: string, password: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -276,16 +276,16 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Logs out current logged in user session */ - public logoutUser(options?: Configuration): RequestContext { + public async logoutUser(options?: Configuration): Promise { let config = options || this.configuration; // Path Params @@ -303,24 +303,24 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted * @param user Updated user object */ - public updateUser(username: string, user: User, options?: Configuration): RequestContext { + public async updateUser(username: string, user: User, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -360,17 +360,17 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts index 40a1e2e77bd8..603ae0fd96c5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts @@ -26,7 +26,7 @@ export abstract class SecurityAuthentication { * * @params context the request context which should use this authentication scheme */ - public abstract applySecurityAuthentication(context: RequestContext): void; + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; } @@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication { public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; - context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + context.setHeaderParam("Authorization", "Basic " + btoa(comb)); } } +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies http bearer authentication to a request. + * + */ +export class HttpBearerAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in openapi specification + * @param tokenProvider service that can provide the up-to-date token when needed + */ + public constructor(authName: string, private tokenProvider: TokenProvider) { + super(authName); + } + + public async applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + } +} + // TODO: How to handle oauth2 authentication! export class OAuth2Authentication extends SecurityAuthentication { public constructor(authName: string) { @@ -117,6 +142,7 @@ export type AuthMethods = { export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } @@ -125,19 +151,18 @@ export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petst * Creates the authentication methods from a swagger description. * */ -export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { - let authMethods: AuthMethods = { - } +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} - if (!conf) { - return authMethods; - } + if (!config) { + return authMethods; + } - if (conf["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + if (config["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); } - if (conf["petstore_auth"]) { + if (config["petstore_auth"]) { authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/default/package-lock.json index 94caf0f4b222..a21ee9c9e472 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/builds/default/package-lock.json @@ -97,9 +97,9 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "typescript": { - "version": "2.9.2", - "resolved": false, - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", "dev": true }, "url-parse": { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/package.json b/samples/openapi3/client/petstore/typescript/builds/default/package.json index 7bcc9bd25a18..aaebe4e7687e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/default/package.json @@ -26,6 +26,6 @@ "url-parse": "^1.4.3" }, "devDependencies": { - "typescript": "^2.9.2" + "typescript": "^3.9.3" } } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/servers.ts b/samples/openapi3/client/petstore/typescript/builds/default/servers.ts index 2819fdbe4274..2124324986d7 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/servers.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/servers.ts @@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { - - public constructor(private url: string, private variableConfiguration: T) { +export class ServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); } - - /** - * Sets the value of the variables of this server. - * - * @param variableConfiguration a partial variable configuration for the variables contained in the url - */ - public setVariables(variableConfiguration: Partial) { - for (const key in variableConfiguration) { - const val = variableConfiguration[key] - // We know that val isn't undefined here - hopefully - if (val !== undefined) { - this.variableConfiguration[key] = val as T[Extract]; - } - } - } public getConfiguration(): T { return this.variableConfiguration @@ -34,7 +26,7 @@ export class ServerConfiguration { let replacedUrl = this.url; for (const key in this.variableConfiguration) { var re = new RegExp("{" + key + "}","g"); - replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); } return replacedUrl } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts index cdc77b530a78..35d8b2c428f7 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -1,7 +1,7 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from '../rxjsStub'; +import { Observable, of, from } from '../rxjsStub'; import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; @@ -30,10 +30,10 @@ export class ObservablePetApi { * @param pet Pet object that needs to be added to the store */ public addPet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(pet, options); + const requestContextPromise = this.requestFactory.addPet(pet, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -54,10 +54,10 @@ export class ObservablePetApi { * @param apiKey */ public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deletePet(petId, apiKey, options); + const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -78,10 +78,10 @@ export class ObservablePetApi { * @param status Status values that need to be considered for filter */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByStatus(status, options); + const requestContextPromise = this.requestFactory.findPetsByStatus(status, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -102,10 +102,10 @@ export class ObservablePetApi { * @param tags Tags to filter by */ public findPetsByTags(tags: Array, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByTags(tags, options); + const requestContextPromise = this.requestFactory.findPetsByTags(tags, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -126,10 +126,10 @@ export class ObservablePetApi { * @param petId ID of pet to return */ public getPetById(petId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getPetById(petId, options); + const requestContextPromise = this.requestFactory.getPetById(petId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -149,10 +149,10 @@ export class ObservablePetApi { * @param pet Pet object that needs to be added to the store */ public updatePet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(pet, options); + const requestContextPromise = this.requestFactory.updatePet(pet, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -174,10 +174,10 @@ export class ObservablePetApi { * @param status Updated status of the pet */ public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); + const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -199,10 +199,10 @@ export class ObservablePetApi { * @param file file to upload */ public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { - const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -241,10 +241,10 @@ export class ObservableStoreApi { * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteOrder(orderId, options); + const requestContextPromise = this.requestFactory.deleteOrder(orderId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -264,10 +264,10 @@ export class ObservableStoreApi { * Returns pet inventories by status */ public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { - const requestContext = this.requestFactory.getInventory(options); + const requestContextPromise = this.requestFactory.getInventory(options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -288,10 +288,10 @@ export class ObservableStoreApi { * @param orderId ID of pet that needs to be fetched */ public getOrderById(orderId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getOrderById(orderId, options); + const requestContextPromise = this.requestFactory.getOrderById(orderId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -311,10 +311,10 @@ export class ObservableStoreApi { * @param order order placed for purchasing the pet */ public placeOrder(order: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(order, options); + const requestContextPromise = this.requestFactory.placeOrder(order, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -353,10 +353,10 @@ export class ObservableUserApi { * @param user Created user object */ public createUser(user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(user, options); + const requestContextPromise = this.requestFactory.createUser(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -376,10 +376,10 @@ export class ObservableUserApi { * @param user List of user object */ public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); + const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -399,10 +399,10 @@ export class ObservableUserApi { * @param user List of user object */ public createUsersWithListInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(user, options); + const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -423,10 +423,10 @@ export class ObservableUserApi { * @param username The name that needs to be deleted */ public deleteUser(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteUser(username, options); + const requestContextPromise = this.requestFactory.deleteUser(username, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -446,10 +446,10 @@ export class ObservableUserApi { * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.getUserByName(username, options); + const requestContextPromise = this.requestFactory.getUserByName(username, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -470,10 +470,10 @@ export class ObservableUserApi { * @param password The password for login in clear text */ public loginUser(username: string, password: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.loginUser(username, password, options); + const requestContextPromise = this.requestFactory.loginUser(username, password, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -492,10 +492,10 @@ export class ObservableUserApi { * Logs out current logged in user session */ public logoutUser(options?: Configuration): Observable { - const requestContext = this.requestFactory.logoutUser(options); + const requestContextPromise = this.requestFactory.logoutUser(options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -517,10 +517,10 @@ export class ObservableUserApi { * @param user Updated user object */ public updateUser(username: string, user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, user, options); + const requestContextPromise = this.requestFactory.updateUser(username, user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts index 68e401b36df0..3eeb7bd4038e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -18,7 +18,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { * Add a new pet to the store * @param pet Pet object that needs to be added to the store */ - public addPet(pet: Pet, options?: Configuration): RequestContext { + public async addPet(pet: Pet, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'pet' is not null or undefined @@ -53,23 +53,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Deletes a pet * @param petId Pet id to delete * @param apiKey */ - public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext { + public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -96,23 +96,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Multiple status values can be provided with comma separated strings * Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext { + public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'status' is not null or undefined @@ -139,23 +139,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags(tags: Array, options?: Configuration): RequestContext { + public async findPetsByTags(tags: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'tags' is not null or undefined @@ -182,23 +182,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Returns a single pet * Find pet by ID * @param petId ID of pet to return */ - public getPetById(petId: number, options?: Configuration): RequestContext { + public async getPetById(petId: number, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -223,22 +223,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Update an existing pet * @param pet Pet object that needs to be added to the store */ - public updatePet(pet: Pet, options?: Configuration): RequestContext { + public async updatePet(pet: Pet, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'pet' is not null or undefined @@ -273,24 +273,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * 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: number, name?: string, status?: string, options?: Configuration): RequestContext { + public async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -327,24 +327,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setBody(localVarFormParams); // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * uploads an image * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext { + public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'petId' is not null or undefined @@ -381,17 +381,17 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { requestContext.setBody(localVarFormParams); // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["petstore_auth"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index 15b86c2bcf02..866a211ca323 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -18,7 +18,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { * Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ - public deleteOrder(orderId: string, options?: Configuration): RequestContext { + public async deleteOrder(orderId: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'orderId' is not null or undefined @@ -43,17 +43,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - public getInventory(options?: Configuration): RequestContext { + public async getInventory(options?: Configuration): Promise { let config = options || this.configuration; // Path Params @@ -71,23 +71,23 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: number, options?: Configuration): RequestContext { + public async getOrderById(orderId: number, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'orderId' is not null or undefined @@ -112,17 +112,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Place an order for a pet * @param order order placed for purchasing the pet */ - public placeOrder(order: Order, options?: Configuration): RequestContext { + public async placeOrder(order: Order, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'order' is not null or undefined @@ -155,12 +155,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts index ab56faf47700..83aae43a582c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -18,7 +18,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { * Create user * @param user Created user object */ - public createUser(user: User, options?: Configuration): RequestContext { + public async createUser(user: User, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -51,22 +51,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Creates list of users with given input array * @param user List of user object */ - public createUsersWithArrayInput(user: Array, options?: Configuration): RequestContext { + public async createUsersWithArrayInput(user: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -99,22 +99,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Creates list of users with given input array * @param user List of user object */ - public createUsersWithListInput(user: Array, options?: Configuration): RequestContext { + public async createUsersWithListInput(user: Array, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'user' is not null or undefined @@ -147,23 +147,23 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * This can only be done by the logged in user. * Delete user * @param username The name that needs to be deleted */ - public deleteUser(username: string, options?: Configuration): RequestContext { + public async deleteUser(username: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -188,22 +188,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName(username: string, options?: Configuration): RequestContext { + public async getUserByName(username: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -228,18 +228,18 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Logs user into the system * @param username The user name for login * @param password The password for login in clear text */ - public loginUser(username: string, password: string, options?: Configuration): RequestContext { + public async loginUser(username: string, password: string, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -275,16 +275,16 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - // Apply auth methods - - return requestContext; + + // Apply auth methods + + return requestContext; } - + /** * Logs out current logged in user session */ - public logoutUser(options?: Configuration): RequestContext { + public async logoutUser(options?: Configuration): Promise { let config = options || this.configuration; // Path Params @@ -302,24 +302,24 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + /** * This can only be done by the logged in user. * Updated user * @param username name that need to be deleted * @param user Updated user object */ - public updateUser(username: string, user: User, options?: Configuration): RequestContext { + public async updateUser(username: string, user: User, options?: Configuration): Promise { let config = options || this.configuration; // verify required parameter 'username' is not null or undefined @@ -359,17 +359,17 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { contentType ); requestContext.setBody(serializedBody); - - let authMethod = null; - // Apply auth methods - authMethod = config.authMethods["api_key"] - if (authMethod) { - authMethod.applySecurityAuthentication(requestContext); - } - - return requestContext; + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; } - + } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts index 40a1e2e77bd8..603ae0fd96c5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts @@ -26,7 +26,7 @@ export abstract class SecurityAuthentication { * * @params context the request context which should use this authentication scheme */ - public abstract applySecurityAuthentication(context: RequestContext): void; + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; } @@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication { public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; - context.setHeaderParam("Authentication", "Basic " + btoa(comb)); + context.setHeaderParam("Authorization", "Basic " + btoa(comb)); } } +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies http bearer authentication to a request. + * + */ +export class HttpBearerAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in openapi specification + * @param tokenProvider service that can provide the up-to-date token when needed + */ + public constructor(authName: string, private tokenProvider: TokenProvider) { + super(authName); + } + + public async applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + } +} + // TODO: How to handle oauth2 authentication! export class OAuth2Authentication extends SecurityAuthentication { public constructor(authName: string) { @@ -117,6 +142,7 @@ export type AuthMethods = { export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } @@ -125,19 +151,18 @@ export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petst * Creates the authentication methods from a swagger description. * */ -export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { - let authMethods: AuthMethods = { - } +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} - if (!conf) { - return authMethods; - } + if (!config) { + return authMethods; + } - if (conf["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + if (config["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); } - if (conf["petstore_auth"]) { + if (config["petstore_auth"]) { authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts index 225d72814d7d..5b163b2626c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts @@ -144,7 +144,7 @@ export class SelfDecodingBody implements ResponseBody { return new Promise((resolve, reject) => { const reader = new FileReader(); - reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("load", () => resolve(reader.result as string)); reader.addEventListener("error", () => reject(reader.error)); reader.readAsText(data); }); diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json index dd9642223ad4..62a0dba628d6 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json @@ -43,9 +43,9 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", "dev": true }, "url-parse": { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/package.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package.json index 0fc169d48802..65361baea547 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/package.json @@ -24,6 +24,6 @@ "url-parse": "^1.4.3" }, "devDependencies": { - "typescript": "^2.9.2" + "typescript": "^3.9.3" } } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts index 2819fdbe4274..2124324986d7 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts @@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { - - public constructor(private url: string, private variableConfiguration: T) { +export class ServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); } - - /** - * Sets the value of the variables of this server. - * - * @param variableConfiguration a partial variable configuration for the variables contained in the url - */ - public setVariables(variableConfiguration: Partial) { - for (const key in variableConfiguration) { - const val = variableConfiguration[key] - // We know that val isn't undefined here - hopefully - if (val !== undefined) { - this.variableConfiguration[key] = val as T[Extract]; - } - } - } public getConfiguration(): T { return this.variableConfiguration @@ -34,7 +26,7 @@ export class ServerConfiguration { let replacedUrl = this.url; for (const key in this.variableConfiguration) { var re = new RegExp("{" + key + "}","g"); - replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString()); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); } return replacedUrl } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts index cdc77b530a78..35d8b2c428f7 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts @@ -1,7 +1,7 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' -import { Observable, of } from '../rxjsStub'; +import { Observable, of, from } from '../rxjsStub'; import {mergeMap, map} from '../rxjsStub'; import { ApiResponse } from '../models/ApiResponse'; @@ -30,10 +30,10 @@ export class ObservablePetApi { * @param pet Pet object that needs to be added to the store */ public addPet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.addPet(pet, options); + const requestContextPromise = this.requestFactory.addPet(pet, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -54,10 +54,10 @@ export class ObservablePetApi { * @param apiKey */ public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deletePet(petId, apiKey, options); + const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -78,10 +78,10 @@ export class ObservablePetApi { * @param status Status values that need to be considered for filter */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByStatus(status, options); + const requestContextPromise = this.requestFactory.findPetsByStatus(status, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -102,10 +102,10 @@ export class ObservablePetApi { * @param tags Tags to filter by */ public findPetsByTags(tags: Array, options?: Configuration): Observable> { - const requestContext = this.requestFactory.findPetsByTags(tags, options); + const requestContextPromise = this.requestFactory.findPetsByTags(tags, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -126,10 +126,10 @@ export class ObservablePetApi { * @param petId ID of pet to return */ public getPetById(petId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getPetById(petId, options); + const requestContextPromise = this.requestFactory.getPetById(petId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -149,10 +149,10 @@ export class ObservablePetApi { * @param pet Pet object that needs to be added to the store */ public updatePet(pet: Pet, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePet(pet, options); + const requestContextPromise = this.requestFactory.updatePet(pet, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -174,10 +174,10 @@ export class ObservablePetApi { * @param status Updated status of the pet */ public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options); + const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -199,10 +199,10 @@ export class ObservablePetApi { * @param file file to upload */ public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { - const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -241,10 +241,10 @@ export class ObservableStoreApi { * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteOrder(orderId, options); + const requestContextPromise = this.requestFactory.deleteOrder(orderId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -264,10 +264,10 @@ export class ObservableStoreApi { * Returns pet inventories by status */ public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { - const requestContext = this.requestFactory.getInventory(options); + const requestContextPromise = this.requestFactory.getInventory(options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -288,10 +288,10 @@ export class ObservableStoreApi { * @param orderId ID of pet that needs to be fetched */ public getOrderById(orderId: number, options?: Configuration): Observable { - const requestContext = this.requestFactory.getOrderById(orderId, options); + const requestContextPromise = this.requestFactory.getOrderById(orderId, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -311,10 +311,10 @@ export class ObservableStoreApi { * @param order order placed for purchasing the pet */ public placeOrder(order: Order, options?: Configuration): Observable { - const requestContext = this.requestFactory.placeOrder(order, options); + const requestContextPromise = this.requestFactory.placeOrder(order, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -353,10 +353,10 @@ export class ObservableUserApi { * @param user Created user object */ public createUser(user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUser(user, options); + const requestContextPromise = this.requestFactory.createUser(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -376,10 +376,10 @@ export class ObservableUserApi { * @param user List of user object */ public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithArrayInput(user, options); + const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -399,10 +399,10 @@ export class ObservableUserApi { * @param user List of user object */ public createUsersWithListInput(user: Array, options?: Configuration): Observable { - const requestContext = this.requestFactory.createUsersWithListInput(user, options); + const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -423,10 +423,10 @@ export class ObservableUserApi { * @param username The name that needs to be deleted */ public deleteUser(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.deleteUser(username, options); + const requestContextPromise = this.requestFactory.deleteUser(username, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -446,10 +446,10 @@ export class ObservableUserApi { * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName(username: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.getUserByName(username, options); + const requestContextPromise = this.requestFactory.getUserByName(username, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -470,10 +470,10 @@ export class ObservableUserApi { * @param password The password for login in clear text */ public loginUser(username: string, password: string, options?: Configuration): Observable { - const requestContext = this.requestFactory.loginUser(username, password, options); + const requestContextPromise = this.requestFactory.loginUser(username, password, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -492,10 +492,10 @@ export class ObservableUserApi { * Logs out current logged in user session */ public logoutUser(options?: Configuration): Observable { - const requestContext = this.requestFactory.logoutUser(options); + const requestContextPromise = this.requestFactory.logoutUser(options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } @@ -517,10 +517,10 @@ export class ObservableUserApi { * @param user Updated user object */ public updateUser(username: string, user: User, options?: Configuration): Observable { - const requestContext = this.requestFactory.updateUser(username, user, options); + const requestContextPromise = this.requestFactory.updateUser(username, user, options); // build promise chain - let middlewarePreObservable = of(requestContext); + let middlewarePreObservable = from(requestContextPromise); for (let middleware of this.configuration.middleware) { middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); } diff --git a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json index 60e8e1b6f4bb..6760ebac1687 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json @@ -1259,6 +1259,27 @@ } } }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "asynckit": { "version": "0.4.0", "bundled": true From d8de81b7c61ae448f018593d4d1346c1e294eb77 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 01:14:14 +0200 Subject: [PATCH 71/85] Add TS-Rewrite-Jquery tests node_modules to travis caching --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2bb05366fd2c..b57dcadbd70d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,8 @@ cache: - $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor - $HOME/samples/client/petstore/ruby/vendor/bundle - $HOME/samples/client/petstore/python/.venv/ - - $HOME/samples/client/petstore/typescript/tests/default/node_modules + - $HOME/samples/openapi3/client/petstore/typescript/tests/default/node_modules + - $HOME/samples/openapi3/client/petstore/typescript/tests/jquery/node_modules - $HOME/samples/client/petstore/typescript-node/npm/node_modules - $HOME/samples/client/petstore/typescript-node/npm/typings/ - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules From 9705ec9c01db7725ac64908aeafcf7bd7cbfe69e Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 01:19:32 +0200 Subject: [PATCH 72/85] Remove NoAuthentication --- .../main/resources/typescript/auth/auth.mustache | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 09d927066a04..d64eb2b25826 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -30,21 +30,6 @@ export abstract class SecurityAuthentication { } -/** - * Applies no authentication. - * - */ -export class NoAuthentication extends SecurityAuthentication { - - public constructor() { - super("_no_auth"); - } - - public applySecurityAuthentication(_context: RequestContext) { - - } -} - /** * Applies an api key to the request context. * From 21861bd27f82111ec99f8fd10911476c3be0d86e Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 01:28:11 +0200 Subject: [PATCH 73/85] Added file to generate TS samples on Windows --- bin/windows/typescript.bat | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 bin/windows/typescript.bat diff --git a/bin/windows/typescript.bat b/bin/windows/typescript.bat new file mode 100755 index 000000000000..de3a2ec77878 --- /dev/null +++ b/bin/windows/typescript.bat @@ -0,0 +1,13 @@ +set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M + +set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\default --additional-properties=platform=node,npmName=ts-petstore-client +java %JAVA_OPTS% -jar %executable% %ags% + +ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\jquery --additional-properties=framework=jquery,npmName=ts-petstore-client +java %JAVA_OPTS% -jar %executable% %ags% From 86daa2b9940039b8d9c11d026fa24c550221def9 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 01:30:45 +0200 Subject: [PATCH 74/85] Exclude btoa in browser --- .../src/main/resources/typescript/auth/auth.mustache | 2 ++ .../src/main/resources/typescript/package.mustache | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index d64eb2b25826..10080d47c048 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -1,7 +1,9 @@ import {RequestContext} from '../http/http'; // typings for btoa are incorrect +{{#node}} //@ts-ignore import * as btoa from "btoa"; +{{/node}} /** * Base class for all authentication schemes. diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 50475a5d4675..c41281ab8933 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -43,7 +43,9 @@ {{#useRxJS}} "rxjs": "^6.4.0", {{/useRxJS}} + {{#node}} "btoa": "^1.2.1", + {{/node}} "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, From f8a42315c0ff415ed468f6a6cc11d21ad458e231 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 02:48:55 +0200 Subject: [PATCH 75/85] Regen samples --- .../resources/typescript/auth/auth.mustache | 3 +- .../resources/typescript/package.mustache | 28 +++++++++---------- .../typescript/builds/default/auth/auth.ts | 16 ----------- .../typescript/builds/jquery/auth/auth.ts | 18 ------------ .../typescript/builds/jquery/package.json | 1 - 5 files changed, 15 insertions(+), 51 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 10080d47c048..261f70b3226b 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -1,10 +1,11 @@ import {RequestContext} from '../http/http'; // typings for btoa are incorrect +{{#platforms}} {{#node}} //@ts-ignore import * as btoa from "btoa"; {{/node}} - +{{/platforms}} /** * Base class for all authentication schemes. * diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index c41281ab8933..14d9b9e8dfd1 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -18,34 +18,32 @@ }, "dependencies": { {{#frameworks}} - {{#fetch-api}} - {{#platforms}} - {{#node}} + {{#fetch-api}} + {{#platforms}} + {{#node}} "node-fetch": "^2.6.0", "@types/node-fetch": "^2.5.7", - {{/node}} - {{#browser}} + {{/node}} + {{#browser}} "whatwg-fetch": "^3.0.0", - {{/browser}} - {{/platforms}} - {{/fetch-api}} - {{#jquery}} + {{/browser}} + {{/platforms}} + {{/fetch-api}} + {{#jquery}} "@types/jquery": "^3.3.29", "jquery": "^3.4.1", - {{/jquery}} + {{/jquery}} {{/frameworks}} {{#platforms}} - {{#node}} + {{#node}} "@types/node": "*", "form-data": "^2.5.0", - {{/node}} + "btoa": "^1.2.1", + {{/node}} {{/platforms}} {{#useRxJS}} "rxjs": "^6.4.0", {{/useRxJS}} - {{#node}} - "btoa": "^1.2.1", - {{/node}} "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, diff --git a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts index 603ae0fd96c5..8a3686484567 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts @@ -2,7 +2,6 @@ import {RequestContext} from '../http/http'; // typings for btoa are incorrect //@ts-ignore import * as btoa from "btoa"; - /** * Base class for all authentication schemes. * @@ -30,21 +29,6 @@ export abstract class SecurityAuthentication { } -/** - * Applies no authentication. - * - */ -export class NoAuthentication extends SecurityAuthentication { - - public constructor() { - super("_no_auth"); - } - - public applySecurityAuthentication(_context: RequestContext) { - - } -} - /** * Applies an api key to the request context. * diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts index 603ae0fd96c5..5601b82c3172 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts @@ -1,8 +1,5 @@ import {RequestContext} from '../http/http'; // typings for btoa are incorrect -//@ts-ignore -import * as btoa from "btoa"; - /** * Base class for all authentication schemes. * @@ -30,21 +27,6 @@ export abstract class SecurityAuthentication { } -/** - * Applies no authentication. - * - */ -export class NoAuthentication extends SecurityAuthentication { - - public constructor() { - super("_no_auth"); - } - - public applySecurityAuthentication(_context: RequestContext) { - - } -} - /** * Applies an api key to the request context. * diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/package.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package.json index 65361baea547..ccacdf6b7158 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/package.json +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/package.json @@ -19,7 +19,6 @@ "dependencies": { "@types/jquery": "^3.3.29", "jquery": "^3.4.1", - "btoa": "^1.2.1", "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, From 3aa2f22d98ae4ec652c0c28d22cb8c25e16fbe4c Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 02:50:12 +0200 Subject: [PATCH 76/85] Remove outdated ToDo comments --- .../languages/TypeScriptClientCodegen.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index e58429a589fb..63b41c25cec3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -145,7 +145,6 @@ public TypeScriptClientCodegen() { typeMapping.put("date", "string"); typeMapping.put("DateTime", "Date"); typeMapping.put("binary", "any"); - // TODO: allow other types for file e.g. Blob typeMapping.put("File", "any"); typeMapping.put("ByteArray", "string"); typeMapping.put("UUID", "string"); @@ -167,7 +166,6 @@ public TypeScriptClientCodegen() { CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { - // TODO: improve description? frameworkOption.addEnum(option, option); } frameworkOption.defaultValue(FRAMEWORKS[0]); @@ -175,15 +173,11 @@ public TypeScriptClientCodegen() { CliOption platformOption = new CliOption(TypeScriptClientCodegen.PLATFORM_SWITCH, TypeScriptClientCodegen.PLATFORM_SWITCH_DESC); for (String option: TypeScriptClientCodegen.PLATFORMS) { - // TODO: improve description? platformOption.addEnum(option, option); } platformOption.defaultValue(PLATFORMS[0]); cliOptions.add(platformOption); - - - // TODO: gen package.json? //Documentation supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); @@ -204,12 +198,10 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("model" + File.separator + "models_all.mustache", "models", "all.ts")); - // TODO: add supporting files depending on cli parameter e.g. fetch vs angular supportingFiles.add(new SupportingFile("types" + File.separator + "PromiseAPI.mustache", "types", "PromiseAPI.ts")); supportingFiles.add(new SupportingFile("types" + File.separator + "ObservableAPI.mustache", "types", "ObservableAPI.ts")); // models - // TODO: properly set model and api packages this.setModelPackage(""); supportingFiles.add(new SupportingFile("model" + File.separator + "ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); modelTemplateFiles.put("model" + File.separator + "model.mustache", ".ts"); @@ -317,7 +309,6 @@ private String getReturnType(List responses) { boolean atLeastOneSuccess = false; boolean addVoid = false; for (CodegenResponse response: responses) { - // TODO: we should probably catch an exception here if (response.is2xx) { if (response.dataType != null) { if (!firstReturnType) { @@ -454,20 +445,6 @@ protected String getParameterDataType(Parameter parameter, Schema p) { return numericEnumValuesToEnumTypeUnion(new ArrayList(p.getEnum())); } } - /* TODO revise the logic below - else if (ModelUtils.isDateSchema(p)) { - // Handle date enums - DateSchema sp = (DateSchema) p; - if (sp.getEnum() != null) { - return enumValuesToEnumTypeUnion(sp.getEnum(), "string"); - } - } else if (ModelUtils.isDateTimeSchema(p)) { - // Handle datetime enums - DateTimeSchema sp = (DateTimeSchema) p; - if (sp.getEnum() != null) { - return enumValuesToEnumTypeUnion(sp.getEnum(), "string"); - } - }*/ return this.getTypeDeclaration(p); } @@ -848,7 +825,6 @@ public String getTypeDeclaration(Schema p) { inner = (Schema) p.getAdditionalProperties(); return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; } else if (ModelUtils.isFileSchema(p)) { - // TODO: Change type declaration return "HttpFile"; } else if (ModelUtils.isBinarySchema(p)) { return "any"; From af8f6ff3eff44a67239aef2e5afd56017c34bb51 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 19:49:49 +0200 Subject: [PATCH 77/85] Document and optimize `getReturnType` in TSClientCodegen --- .../languages/TypeScriptClientCodegen.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 63b41c25cec3..3c6bed5646a5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2020 OpenAPI-Generator Contributors (https://openapi-generator.tech) * Copyright 2018 SmartBear Software * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -303,32 +303,28 @@ public Map postProcessOperationsWithModels(Map o return operations; } + /** + * Returns the correct return type based on all 2xx HTTP responses defined for an operation. + * @param responses all CodegenResponses defined for one operation + * @return TypeScript return type + */ private String getReturnType(List responses) { - StringBuilder returnType = new StringBuilder(); - boolean firstReturnType = true; - boolean atLeastOneSuccess = false; - boolean addVoid = false; + Set returnTypes = new HashSet(); for (CodegenResponse response: responses) { if (response.is2xx) { if (response.dataType != null) { - if (!firstReturnType) { - returnType.append(" | "); - } - returnType.append(response.dataType); - firstReturnType = false; - atLeastOneSuccess = true; + returnTypes.add(response.dataType); } else { - addVoid = true; + returnTypes.add("void"); } } } - if (!atLeastOneSuccess) { - return null; - } else if (addVoid) { - returnType.append(" | void"); - } - return returnType.toString(); + if (returnTypes.size() == 0) { + return null; + } + + return String.join(" | ", returnTypes); } private String getModelnameFromModelFilename(String filename) { From d9e051938d99c4293dfb102f6db0fbc2e279f3c1 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 22:38:56 +0200 Subject: [PATCH 78/85] Added option to generate objects for operation function arguments --- .travis.yml | 1 + bin/typescript.sh | 5 + bin/windows/typescript.bat | 3 + .../languages/TypeScriptClientCodegen.java | 6 + .../main/resources/typescript/index.mustache | 17 +- .../typescript/types/ObjectParamAPI.mustache | 60 + pom.xml | 2 + .../typescript/builds/default/index.ts | 4 +- .../builds/default/types/ObjectParamAPI.ts | 442 +++++ .../typescript/builds/jquery/index.ts | 4 +- .../builds/jquery/types/APIInterfaces.ts | 166 ++ .../builds/jquery/types/ObjectParamAPI.ts | 442 +++++ .../builds/object_params/.gitignore | 1 + .../object_params/.openapi-generator-ignore | 23 + .../object_params/.openapi-generator/VERSION | 1 + .../typescript/builds/object_params/README.md | 30 + .../builds/object_params/apis/PetApi.ts | 650 ++++++++ .../builds/object_params/apis/StoreApi.ts | 295 ++++ .../builds/object_params/apis/UserApi.ts | 587 +++++++ .../builds/object_params/apis/baseapi.ts | 37 + .../builds/object_params/apis/exception.ts | 14 + .../builds/object_params/auth/auth.ts | 154 ++ .../builds/object_params/configuration.ts | 60 + .../builds/object_params/git_push.sh | 52 + .../builds/object_params/http/http.ts | 194 +++ .../object_params/http/isomorphic-fetch.ts | 31 + .../typescript/builds/object_params/index.ts | 11 + .../builds/object_params/middleware.ts | 66 + .../object_params/models/ApiResponse.ts | 52 + .../builds/object_params/models/Category.ts | 45 + .../object_params/models/InlineObject.ts | 48 + .../object_params/models/InlineObject1.ts | 48 + .../object_params/models/ObjectSerializer.ts | 240 +++ .../builds/object_params/models/Order.ts | 79 + .../builds/object_params/models/Pet.ts | 81 + .../builds/object_params/models/Tag.ts | 45 + .../builds/object_params/models/User.ts | 90 ++ .../builds/object_params/models/all.ts | 8 + .../builds/object_params/package-lock.json | 115 ++ .../builds/object_params/package.json | 31 + .../builds/object_params/rxjsStub.ts | 27 + .../builds/object_params/servers.ts | 47 + .../builds/object_params/tsconfig.json | 29 + .../object_params/types/ObjectParamAPI.ts | 442 +++++ .../object_params/types/ObservableAPI.ts | 542 +++++++ .../builds/object_params/types/PromiseAPI.ts | 254 +++ .../typescript/builds/object_params/util.ts | 28 + .../tests/default/package-lock.json | 38 +- .../tests/default/test/api/PetApi.test.ts | 18 +- .../tests/default/test/auth/auth.test.ts | 12 - .../typescript/tests/jquery/package-lock.json | 1 - .../tests/jquery/test/api/PetApi.test.ts | 2 +- .../typescript/tests/object_params/.gitignore | 1 + .../tests/object_params/package-lock.json | 1416 +++++++++++++++++ .../tests/object_params/package.json | 33 + .../typescript/tests/object_params/pom.xml | 59 + .../object_params/test/api/PetApi.test.ts | 131 ++ .../tests/object_params/test/api/pet.png | Bin 0 -> 1122 bytes .../tests/object_params/tsconfig.json | 20 + 59 files changed, 7272 insertions(+), 68 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache create mode 100644 samples/openapi3/client/petstore/typescript/builds/default/types/ObjectParamAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/jquery/types/APIInterfaces.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/jquery/types/ObjectParamAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/.gitignore create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator-ignore create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/VERSION create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/README.md create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/apis/PetApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/apis/StoreApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/apis/UserApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/apis/baseapi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/apis/exception.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/git_push.sh create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/http/isomorphic-fetch.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/index.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/middleware.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject1.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/models/all.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/package-lock.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/package.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/rxjsStub.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/types/ObjectParamAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/util.ts create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/.gitignore create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/package.json create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/test/api/pet.png create mode 100644 samples/openapi3/client/petstore/typescript/tests/object_params/tsconfig.json diff --git a/.travis.yml b/.travis.yml index b57dcadbd70d..80351132561e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ cache: - $HOME/samples/client/petstore/python/.venv/ - $HOME/samples/openapi3/client/petstore/typescript/tests/default/node_modules - $HOME/samples/openapi3/client/petstore/typescript/tests/jquery/node_modules + - $HOME/samples/openapi3/client/petstore/typescript/tests/object_params/node_modules - $HOME/samples/client/petstore/typescript-node/npm/node_modules - $HOME/samples/client/petstore/typescript-node/npm/typings/ - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules diff --git a/bin/typescript.sh b/bin/typescript.sh index 38846529cf7e..346724c00268 100755 --- a/bin/typescript.sh +++ b/bin/typescript.sh @@ -35,3 +35,8 @@ echo "Creating jquery client!" ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" java $JAVA_OPTS -jar $executable $ags + +echo "Creating fetch object client!" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/typescript.bat b/bin/windows/typescript.bat index de3a2ec77878..fe4dae009466 100755 --- a/bin/windows/typescript.bat +++ b/bin/windows/typescript.bat @@ -11,3 +11,6 @@ java %JAVA_OPTS% -jar %executable% %ags% ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\jquery --additional-properties=framework=jquery,npmName=ts-petstore-client java %JAVA_OPTS% -jar %executable% %ags% + +set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 3c6bed5646a5..1b3517c5fae4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -57,6 +57,10 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String USE_RXJS_SWITCH = "useRxJS"; private static final String USE_RXJS_SWITCH_DESC = "Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework."; + private static final String USE_OBJECT_PARAMS_SWITCH = "useObjectParameters"; + private static final String USE_OBJECT_PARAMS_DESC = "Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument."; + + private final Map frameworkToHttpLibMap; // NPM Options @@ -163,6 +167,7 @@ public TypeScriptClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH, TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH).defaultValue("false")); CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { @@ -200,6 +205,7 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("types" + File.separator + "PromiseAPI.mustache", "types", "PromiseAPI.ts")); supportingFiles.add(new SupportingFile("types" + File.separator + "ObservableAPI.mustache", "types", "ObservableAPI.ts")); + supportingFiles.add(new SupportingFile("types" + File.separator + "ObjectParamAPI.mustache", "types", "ObjectParamAPI.ts")); // models this.setModelPackage(""); diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache index 3ac251c10ce6..d5829b82d26f 100644 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -8,10 +8,19 @@ export * from './apis/exception'; export * from './servers'; {{#useRxJS}} - export * from './types/ObservableAPI'; - export { Middleware } from './middleware'; +export { Middleware } from './middleware'; {{/useRxJS}} {{^useRxJS}} - export * from './types/PromiseAPI'; - export { PromiseMiddleware as Middleware } from './middleware'; +export { PromiseMiddleware as Middleware } from './middleware'; {{/useRxJS}} +{{#useObjectParameters}} +export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI'; +{{/useObjectParameters}} +{{^useObjectParameters}} +{{#useRxJS}} +export { {{#apiInfo}}{{#apis}}{{#operations}}Observable{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObservableAPI'; +{{/useRxJS}} +{{^useRxJS}} +export { {{#apiInfo}}{{#apis}}{{#operations}}Promise{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/PromiseAPI'; +{{/useRxJS}} +{{/useObjectParameters}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache new file mode 100644 index 000000000000..16d926d1c55f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache @@ -0,0 +1,60 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +{{#models}} +{{#model}} +import { {{{ classname }}} } from '../models/{{{ classFilename }}}'; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} + +{{#operations}} +import { Observable{{classname}} } from "./ObservableAPI"; +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; + +{{#operation}} +export interface {{classname}}{{operationIdCamelCase}}Request { + {{#allParams}} + /** + * {{description}} + * @type {{dataType}} + * @memberof {{classname}}{{nickname}} + */ + {{paramName}}{{^required}}?{{/required}}: {{{dataType}}} + {{/allParams}} +} + +{{/operation}} + +export class Object{{classname}} { + private api: Observable{{classname}} + + public constructor(configuration: Configuration, requestFactory?: {{classname}}RequestFactory, responseProcessor?: {{classname}}ResponseProcessor) { + this.api = new Observable{{classname}}(configuration, requestFactory, responseProcessor); + } + +{{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + * @param param the request object + */ + public {{nickname}}(param: {{classname}}{{operationIdCamelCase}}Request, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + return this.api.{{nickname}}({{#allParams}}param.{{paramName}}, {{/allParams}} options){{^useRxJS}}.toPromise(){{/useRxJS}}; + } + +{{/operation}} + +} + +{{/operations}} + + +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/pom.xml b/pom.xml index eb1ccb213f1b..605edb001e26 100644 --- a/pom.xml +++ b/pom.xml @@ -1287,6 +1287,8 @@ samples/openapi3/client/petstore/typescript/tests/default samples/openapi3/client/petstore/typescript/builds/jquery samples/openapi3/client/petstore/typescript/tests/jquery + samples/openapi3/client/petstore/typescript/builds/object_params + samples/openapi3/client/petstore/typescript/tests/object_params samples/client/petstore/typescript-fetch/builds/default samples/client/petstore/typescript-fetch/builds/es6-target samples/client/petstore/typescript-fetch/builds/with-npm-version diff --git a/samples/openapi3/client/petstore/typescript/builds/default/index.ts b/samples/openapi3/client/petstore/typescript/builds/default/index.ts index 575141afce11..994fe9dec6d1 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/index.ts @@ -7,5 +7,5 @@ export { Configuration} from './configuration' export * from './apis/exception'; export * from './servers'; - export * from './types/PromiseAPI'; - export { PromiseMiddleware as Middleware } from './middleware'; +export { PromiseMiddleware as Middleware } from './middleware'; +export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/default/types/ObjectParamAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/ObjectParamAPI.ts new file mode 100644 index 000000000000..10cebbd77dd2 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/ObjectParamAPI.ts @@ -0,0 +1,442 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { ObservablePetApi } from "./ObservableAPI"; +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; + +export interface PetApiAddPetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiaddPet + */ + pet: Pet +} + +export interface PetApiDeletePetRequest { + /** + * Pet id to delete + * @type number + * @memberof PetApideletePet + */ + petId: number + /** + * + * @type string + * @memberof PetApideletePet + */ + apiKey?: string +} + +export interface PetApiFindPetsByStatusRequest { + /** + * Status values that need to be considered for filter + * @type Array<'available' | 'pending' | 'sold'> + * @memberof PetApifindPetsByStatus + */ + status: Array<'available' | 'pending' | 'sold'> +} + +export interface PetApiFindPetsByTagsRequest { + /** + * Tags to filter by + * @type Array<string> + * @memberof PetApifindPetsByTags + */ + tags: Array +} + +export interface PetApiGetPetByIdRequest { + /** + * ID of pet to return + * @type number + * @memberof PetApigetPetById + */ + petId: number +} + +export interface PetApiUpdatePetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiupdatePet + */ + pet: Pet +} + +export interface PetApiUpdatePetWithFormRequest { + /** + * ID of pet that needs to be updated + * @type number + * @memberof PetApiupdatePetWithForm + */ + petId: number + /** + * Updated name of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + name?: string + /** + * Updated status of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + status?: string +} + +export interface PetApiUploadFileRequest { + /** + * ID of pet to update + * @type number + * @memberof PetApiuploadFile + */ + petId: number + /** + * Additional data to pass to server + * @type string + * @memberof PetApiuploadFile + */ + additionalMetadata?: string + /** + * file to upload + * @type HttpFile + * @memberof PetApiuploadFile + */ + file?: HttpFile +} + + +export class ObjectPetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param param the request object + */ + public addPet(param: PetApiAddPetRequest, options?: Configuration): Promise { + return this.api.addPet(param.pet, options).toPromise(); + } + + /** + * Deletes a pet + * @param param the request object + */ + public deletePet(param: PetApiDeletePetRequest, options?: Configuration): Promise { + return this.api.deletePet(param.petId, param.apiKey, options).toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param param the request object + */ + public findPetsByStatus(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise> { + return this.api.findPetsByStatus(param.status, options).toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param param the request object + */ + public findPetsByTags(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise> { + return this.api.findPetsByTags(param.tags, options).toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param param the request object + */ + public getPetById(param: PetApiGetPetByIdRequest, options?: Configuration): Promise { + return this.api.getPetById(param.petId, options).toPromise(); + } + + /** + * Update an existing pet + * @param param the request object + */ + public updatePet(param: PetApiUpdatePetRequest, options?: Configuration): Promise { + return this.api.updatePet(param.pet, options).toPromise(); + } + + /** + * Updates a pet in the store with form data + * @param param the request object + */ + public updatePetWithForm(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise { + return this.api.updatePetWithForm(param.petId, param.name, param.status, options).toPromise(); + } + + /** + * uploads an image + * @param param the request object + */ + public uploadFile(param: PetApiUploadFileRequest, options?: Configuration): Promise { + return this.api.uploadFile(param.petId, param.additionalMetadata, param.file, options).toPromise(); + } + + +} + + + + +import { ObservableStoreApi } from "./ObservableAPI"; +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; + +export interface StoreApiDeleteOrderRequest { + /** + * ID of the order that needs to be deleted + * @type string + * @memberof StoreApideleteOrder + */ + orderId: string +} + +export interface StoreApiGetInventoryRequest { +} + +export interface StoreApiGetOrderByIdRequest { + /** + * ID of pet that needs to be fetched + * @type number + * @memberof StoreApigetOrderById + */ + orderId: number +} + +export interface StoreApiPlaceOrderRequest { + /** + * order placed for purchasing the pet + * @type Order + * @memberof StoreApiplaceOrder + */ + order: Order +} + + +export class ObjectStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param param the request object + */ + public deleteOrder(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise { + return this.api.deleteOrder(param.orderId, options).toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + * @param param the request object + */ + public getInventory(param: StoreApiGetInventoryRequest, options?: Configuration): Promise<{ [key: string]: number; }> { + return this.api.getInventory( options).toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param param the request object + */ + public getOrderById(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise { + return this.api.getOrderById(param.orderId, options).toPromise(); + } + + /** + * Place an order for a pet + * @param param the request object + */ + public placeOrder(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise { + return this.api.placeOrder(param.order, options).toPromise(); + } + + +} + + + + +import { ObservableUserApi } from "./ObservableAPI"; +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; + +export interface UserApiCreateUserRequest { + /** + * Created user object + * @type User + * @memberof UserApicreateUser + */ + user: User +} + +export interface UserApiCreateUsersWithArrayInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithArrayInput + */ + user: Array +} + +export interface UserApiCreateUsersWithListInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithListInput + */ + user: Array +} + +export interface UserApiDeleteUserRequest { + /** + * The name that needs to be deleted + * @type string + * @memberof UserApideleteUser + */ + username: string +} + +export interface UserApiGetUserByNameRequest { + /** + * The name that needs to be fetched. Use user1 for testing. + * @type string + * @memberof UserApigetUserByName + */ + username: string +} + +export interface UserApiLoginUserRequest { + /** + * The user name for login + * @type string + * @memberof UserApiloginUser + */ + username: string + /** + * The password for login in clear text + * @type string + * @memberof UserApiloginUser + */ + password: string +} + +export interface UserApiLogoutUserRequest { +} + +export interface UserApiUpdateUserRequest { + /** + * name that need to be deleted + * @type string + * @memberof UserApiupdateUser + */ + username: string + /** + * Updated user object + * @type User + * @memberof UserApiupdateUser + */ + user: User +} + + +export class ObjectUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param param the request object + */ + public createUser(param: UserApiCreateUserRequest, options?: Configuration): Promise { + return this.api.createUser(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithArrayInput(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithArrayInput(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithListInput(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithListInput(param.user, options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param param the request object + */ + public deleteUser(param: UserApiDeleteUserRequest, options?: Configuration): Promise { + return this.api.deleteUser(param.username, options).toPromise(); + } + + /** + * Get user by user name + * @param param the request object + */ + public getUserByName(param: UserApiGetUserByNameRequest, options?: Configuration): Promise { + return this.api.getUserByName(param.username, options).toPromise(); + } + + /** + * Logs user into the system + * @param param the request object + */ + public loginUser(param: UserApiLoginUserRequest, options?: Configuration): Promise { + return this.api.loginUser(param.username, param.password, options).toPromise(); + } + + /** + * Logs out current logged in user session + * @param param the request object + */ + public logoutUser(param: UserApiLogoutUserRequest, options?: Configuration): Promise { + return this.api.logoutUser( options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param param the request object + */ + public updateUser(param: UserApiUpdateUserRequest, options?: Configuration): Promise { + return this.api.updateUser(param.username, param.user, options).toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts index 575141afce11..994fe9dec6d1 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts @@ -7,5 +7,5 @@ export { Configuration} from './configuration' export * from './apis/exception'; export * from './servers'; - export * from './types/PromiseAPI'; - export { PromiseMiddleware as Middleware } from './middleware'; +export { PromiseMiddleware as Middleware } from './middleware'; +export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/types/APIInterfaces.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/APIInterfaces.ts new file mode 100644 index 000000000000..370e025aa041 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/APIInterfaces.ts @@ -0,0 +1,166 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of, from } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +export interface GenericPetApiInterface { + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + addPet(pet: Pet, options?: Configuration): T1; + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + deletePet(petId: number, apiKey?: string, options?: Configuration): T2; + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): T3; + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + findPetsByTags(tags: Array, options?: Configuration): T4; + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + getPetById(petId: number, options?: Configuration): T5; + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + updatePet(pet: Pet, options?: Configuration): T6; + + /** + * 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 + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): T7; + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): T8; + +} + + + + +export interface GenericStoreApiInterface { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + deleteOrder(orderId: string, options?: Configuration): T1; + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + getInventory(options?: Configuration): T2; + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + getOrderById(orderId: number, options?: Configuration): T3; + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + placeOrder(order: Order, options?: Configuration): T4; + +} + + + + +export interface GenericUserApiInterface { + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + createUser(user: User, options?: Configuration): T1; + + /** + * Creates list of users with given input array + * @param user List of user object + */ + createUsersWithArrayInput(user: Array, options?: Configuration): T2; + + /** + * Creates list of users with given input array + * @param user List of user object + */ + createUsersWithListInput(user: Array, options?: Configuration): T3; + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + deleteUser(username: string, options?: Configuration): T4; + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + getUserByName(username: string, options?: Configuration): T5; + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + loginUser(username: string, password: string, options?: Configuration): T6; + + /** + * Logs out current logged in user session + */ + logoutUser(options?: Configuration): T7; + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + updateUser(username: string, user: User, options?: Configuration): T8; + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObjectParamAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObjectParamAPI.ts new file mode 100644 index 000000000000..10cebbd77dd2 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObjectParamAPI.ts @@ -0,0 +1,442 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { ObservablePetApi } from "./ObservableAPI"; +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; + +export interface PetApiAddPetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiaddPet + */ + pet: Pet +} + +export interface PetApiDeletePetRequest { + /** + * Pet id to delete + * @type number + * @memberof PetApideletePet + */ + petId: number + /** + * + * @type string + * @memberof PetApideletePet + */ + apiKey?: string +} + +export interface PetApiFindPetsByStatusRequest { + /** + * Status values that need to be considered for filter + * @type Array<'available' | 'pending' | 'sold'> + * @memberof PetApifindPetsByStatus + */ + status: Array<'available' | 'pending' | 'sold'> +} + +export interface PetApiFindPetsByTagsRequest { + /** + * Tags to filter by + * @type Array<string> + * @memberof PetApifindPetsByTags + */ + tags: Array +} + +export interface PetApiGetPetByIdRequest { + /** + * ID of pet to return + * @type number + * @memberof PetApigetPetById + */ + petId: number +} + +export interface PetApiUpdatePetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiupdatePet + */ + pet: Pet +} + +export interface PetApiUpdatePetWithFormRequest { + /** + * ID of pet that needs to be updated + * @type number + * @memberof PetApiupdatePetWithForm + */ + petId: number + /** + * Updated name of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + name?: string + /** + * Updated status of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + status?: string +} + +export interface PetApiUploadFileRequest { + /** + * ID of pet to update + * @type number + * @memberof PetApiuploadFile + */ + petId: number + /** + * Additional data to pass to server + * @type string + * @memberof PetApiuploadFile + */ + additionalMetadata?: string + /** + * file to upload + * @type HttpFile + * @memberof PetApiuploadFile + */ + file?: HttpFile +} + + +export class ObjectPetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param param the request object + */ + public addPet(param: PetApiAddPetRequest, options?: Configuration): Promise { + return this.api.addPet(param.pet, options).toPromise(); + } + + /** + * Deletes a pet + * @param param the request object + */ + public deletePet(param: PetApiDeletePetRequest, options?: Configuration): Promise { + return this.api.deletePet(param.petId, param.apiKey, options).toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param param the request object + */ + public findPetsByStatus(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise> { + return this.api.findPetsByStatus(param.status, options).toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param param the request object + */ + public findPetsByTags(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise> { + return this.api.findPetsByTags(param.tags, options).toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param param the request object + */ + public getPetById(param: PetApiGetPetByIdRequest, options?: Configuration): Promise { + return this.api.getPetById(param.petId, options).toPromise(); + } + + /** + * Update an existing pet + * @param param the request object + */ + public updatePet(param: PetApiUpdatePetRequest, options?: Configuration): Promise { + return this.api.updatePet(param.pet, options).toPromise(); + } + + /** + * Updates a pet in the store with form data + * @param param the request object + */ + public updatePetWithForm(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise { + return this.api.updatePetWithForm(param.petId, param.name, param.status, options).toPromise(); + } + + /** + * uploads an image + * @param param the request object + */ + public uploadFile(param: PetApiUploadFileRequest, options?: Configuration): Promise { + return this.api.uploadFile(param.petId, param.additionalMetadata, param.file, options).toPromise(); + } + + +} + + + + +import { ObservableStoreApi } from "./ObservableAPI"; +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; + +export interface StoreApiDeleteOrderRequest { + /** + * ID of the order that needs to be deleted + * @type string + * @memberof StoreApideleteOrder + */ + orderId: string +} + +export interface StoreApiGetInventoryRequest { +} + +export interface StoreApiGetOrderByIdRequest { + /** + * ID of pet that needs to be fetched + * @type number + * @memberof StoreApigetOrderById + */ + orderId: number +} + +export interface StoreApiPlaceOrderRequest { + /** + * order placed for purchasing the pet + * @type Order + * @memberof StoreApiplaceOrder + */ + order: Order +} + + +export class ObjectStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param param the request object + */ + public deleteOrder(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise { + return this.api.deleteOrder(param.orderId, options).toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + * @param param the request object + */ + public getInventory(param: StoreApiGetInventoryRequest, options?: Configuration): Promise<{ [key: string]: number; }> { + return this.api.getInventory( options).toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param param the request object + */ + public getOrderById(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise { + return this.api.getOrderById(param.orderId, options).toPromise(); + } + + /** + * Place an order for a pet + * @param param the request object + */ + public placeOrder(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise { + return this.api.placeOrder(param.order, options).toPromise(); + } + + +} + + + + +import { ObservableUserApi } from "./ObservableAPI"; +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; + +export interface UserApiCreateUserRequest { + /** + * Created user object + * @type User + * @memberof UserApicreateUser + */ + user: User +} + +export interface UserApiCreateUsersWithArrayInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithArrayInput + */ + user: Array +} + +export interface UserApiCreateUsersWithListInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithListInput + */ + user: Array +} + +export interface UserApiDeleteUserRequest { + /** + * The name that needs to be deleted + * @type string + * @memberof UserApideleteUser + */ + username: string +} + +export interface UserApiGetUserByNameRequest { + /** + * The name that needs to be fetched. Use user1 for testing. + * @type string + * @memberof UserApigetUserByName + */ + username: string +} + +export interface UserApiLoginUserRequest { + /** + * The user name for login + * @type string + * @memberof UserApiloginUser + */ + username: string + /** + * The password for login in clear text + * @type string + * @memberof UserApiloginUser + */ + password: string +} + +export interface UserApiLogoutUserRequest { +} + +export interface UserApiUpdateUserRequest { + /** + * name that need to be deleted + * @type string + * @memberof UserApiupdateUser + */ + username: string + /** + * Updated user object + * @type User + * @memberof UserApiupdateUser + */ + user: User +} + + +export class ObjectUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param param the request object + */ + public createUser(param: UserApiCreateUserRequest, options?: Configuration): Promise { + return this.api.createUser(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithArrayInput(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithArrayInput(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithListInput(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithListInput(param.user, options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param param the request object + */ + public deleteUser(param: UserApiDeleteUserRequest, options?: Configuration): Promise { + return this.api.deleteUser(param.username, options).toPromise(); + } + + /** + * Get user by user name + * @param param the request object + */ + public getUserByName(param: UserApiGetUserByNameRequest, options?: Configuration): Promise { + return this.api.getUserByName(param.username, options).toPromise(); + } + + /** + * Logs user into the system + * @param param the request object + */ + public loginUser(param: UserApiLoginUserRequest, options?: Configuration): Promise { + return this.api.loginUser(param.username, param.password, options).toPromise(); + } + + /** + * Logs out current logged in user session + * @param param the request object + */ + public logoutUser(param: UserApiLogoutUserRequest, options?: Configuration): Promise { + return this.api.logoutUser( options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param param the request object + */ + public updateUser(param: UserApiUpdateUserRequest, options?: Configuration): Promise { + return this.api.updateUser(param.username, param.user, options).toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/.gitignore b/samples/openapi3/client/petstore/typescript/builds/object_params/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator-ignore b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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 +# This 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 diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/VERSION b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/VERSION new file mode 100644 index 000000000000..d99e7162d01f --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/README.md b/samples/openapi3/client/petstore/typescript/builds/object_params/README.md new file mode 100644 index 000000000000..80b1ac5cc98b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/README.md @@ -0,0 +1,30 @@ +## ts-petstore-client@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes fetch-api. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install ts-petstore-client@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/PetApi.ts new file mode 100644 index 000000000000..7041341a7089 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/PetApi.ts @@ -0,0 +1,650 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; + +/** + * no description + */ +export class PetApiRequestFactory extends BaseAPIRequestFactory { + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public async addPet(pet: Pet, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(pet, "Pet", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", "")); + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + + + // Path Params + const localVarPath = '/pet/findByStatus'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (status !== undefined) { + requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public async findPetsByTags(tags: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + + + // Path Params + const localVarPath = '/pet/findByTags'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (tags !== undefined) { + requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public async getPetById(petId: number, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public async updatePet(pet: Pet, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(pet, "Pet", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * 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 async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (name !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('name', name as any); + } + if (status !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('status', status as any); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (additionalMetadata !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + if (file !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('file', file.data, file.name); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + + + +export class PetApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to addPet + * @throws ApiException if the response code was not in [200, 299] + */ + public async addPet(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deletePet + * @throws ApiException if the response code was not in [200, 299] + */ + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid pet value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByStatus + * @throws ApiException if the response code was not in [200, 299] + */ + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid status value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByTags + * @throws ApiException if the response code was not in [200, 299] + */ + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid tag value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getPetById + * @throws ApiException if the response code was not in [200, 299] + */ + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePet + * @throws ApiException if the response code was not in [200, 299] + */ + public async updatePet(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Validation exception"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePetWithForm + * @throws ApiException if the response code was not in [200, 299] + */ + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to uploadFile + * @throws ApiException if the response code was not in [200, 299] + */ + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/StoreApi.ts new file mode 100644 index 000000000000..09400e99c083 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/StoreApi.ts @@ -0,0 +1,295 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { Order } from '../models/Order'; + +/** + * no description + */ +export class StoreApiRequestFactory extends BaseAPIRequestFactory { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public async deleteOrder(orderId: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public async getInventory(options?: Configuration): Promise { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/store/inventory'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public async getOrderById(orderId: number, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public async placeOrder(order: Order, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + } + + + // Path Params + const localVarPath = '/store/order'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(order, "Order", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + +} + + + +export class StoreApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteOrder + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getInventory + * @throws ApiException if the response code was not in [200, 299] + */ + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getOrderById + * @throws ApiException if the response code was not in [200, 299] + */ + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to placeOrder + * @throws ApiException if the response code was not in [200, 299] + */ + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid Order"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/UserApi.ts new file mode 100644 index 000000000000..1d43ec7a72b4 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/UserApi.ts @@ -0,0 +1,587 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; + +import { User } from '../models/User'; + +/** + * no description + */ +export class UserApiRequestFactory extends BaseAPIRequestFactory { + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public async createUser(user: User, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); + } + + + // Path Params + const localVarPath = '/user'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "User", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public async createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithArray'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public async createUsersWithListInput(user: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithList'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public async deleteUser(username: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public async getUserByName(username: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public async loginUser(username: string, password: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + + + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + + + // Path Params + const localVarPath = '/user/login'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (username !== undefined) { + requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string", "")); + } + if (password !== undefined) { + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs out current logged in user session + */ + public async logoutUser(options?: Configuration): Promise { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/user/logout'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public async updateUser(username: string, user: User, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "User", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + + + +export class UserApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithArrayInput + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithListInput + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getUserByName + * @throws ApiException if the response code was not in [200, 299] + */ + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to loginUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to logoutUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid user supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/baseapi.ts new file mode 100644 index 000000000000..fe7ee3d15118 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/apis/exception.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/exception.ts new file mode 100644 index 000000000000..b76dca5aa4bc --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/apis/exception.ts @@ -0,0 +1,14 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ +export class ApiException extends Error { + public constructor(public code: number, public body: T) { + super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts new file mode 100644 index 000000000000..8a3686484567 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts @@ -0,0 +1,154 @@ +import {RequestContext} from '../http/http'; +// typings for btoa are incorrect +//@ts-ignore +import * as btoa from "btoa"; +/** + * Base class for all authentication schemes. + * + */ +export abstract class SecurityAuthentication { + + public constructor(private name: string) { + + } + + /* + * + * @return returns the name of the security authentication as specified in OAI + */ + public getName(): string { + return this.name; + } + + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; + +} + +/** + * Applies an api key to the request context. + * + */ +export class APIKeyAuthentication extends SecurityAuthentication { + + /** + * Configures this api key authentication with the necessary properties + * + * @param authName: name of this authentication scheme as specified in the swagger.json + * @param paramName: Parameter name used for the api key + * @param keyLocation: Parameter location, either query, header or cookie. + * @param apiKey: The api key to be used for every request + */ + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + if (this.keyLocation === "header") { + context.setHeaderParam(this.paramName, this.apiKey); + } else if (this.keyLocation === "cookie") { + context.addCookie(this.paramName, this.apiKey); + } else if (this.keyLocation === "query") { + context.setQueryParam(this.paramName, this.apiKey); + } + } +} + + +/** + * Applies basic http authentication to a request. + * + */ +export class HttpBasicAuthentication extends SecurityAuthentication { + + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in swagger json + * @param username username for http basic authentication + * @param password password for http basic authentication + */ + public constructor(authName: string, private username: string, private password: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + let comb = this.username + ":" + this.password; + context.setHeaderParam("Authorization", "Basic " + btoa(comb)); + } +} + +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies http bearer authentication to a request. + * + */ +export class HttpBearerAuthentication extends SecurityAuthentication { + /** + * Configures the http authentication with the required details. + * + * + * @param authName name of the authentication scheme as defined in openapi specification + * @param tokenProvider service that can provide the up-to-date token when needed + */ + public constructor(authName: string, private tokenProvider: TokenProvider) { + super(authName); + } + + public async applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + } +} + +// TODO: How to handle oauth2 authentication! +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + +export type AuthMethods = { + "api_key"?: APIKeyAuthentication, + "petstore_auth"?: OAuth2Authentication, +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } + +/** + * Creates the authentication methods from a swagger description. + * + */ +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} + + if (!config) { + return authMethods; + } + + if (config["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); + } + + if (config["petstore_auth"]) { + authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); + } + + return authMethods; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts new file mode 100644 index 000000000000..73f53c7dd211 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts @@ -0,0 +1,60 @@ +import {HttpLibrary} from './http/http'; +import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; +import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; +import {ServerConfiguration, server1} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + +/** + * Inetrface with which a configuration object can be configured. + * + */ +export interface ConfigurationParameters { + /** + * Default server to use + */ + baseServer?: ServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ + httpApi?: HttpLibrary; + /** + * The middlewares which will be applied to requests and responses + */ + middleware?: Middleware[]; // middleware to apply before/after fetch requests + /** + * configures all middlewares using the promise api instead of observables (which Middleware uses) + */ + promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods + */ + authMethods?: AuthMethodsConfiguration +} + +export class Configuration { + + baseServer: ServerConfiguration; + httpApi: HttpLibrary; + middleware: Middleware[]; + authMethods: AuthMethods; + + /** + * Creates a new configuration object based on the given configuration. + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * @param conf particial configuration + */ + constructor(conf: ConfigurationParameters = {}) { + this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; + this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? + this.middleware = conf.middleware || []; + this.authMethods = configureAuthMethods(conf.authMethods); + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); + } + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/git_push.sh b/samples/openapi3/client/petstore/typescript/builds/object_params/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/git_push.sh @@ -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 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="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="Minor update" + 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 credential 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' + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts new file mode 100644 index 000000000000..6de17431aa26 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts @@ -0,0 +1,194 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; +// typings of url-parse are incorrect... +// @ts-ignore +import * as URLParse from "url-parse"; +import { Observable } from '../rxjsStub'; + +export * from './isomorphic-fetch'; + +/** + * Represents an HTTP method. + */ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +/** + * Represents an HTTP file which will be transferred from or to a server. + */ +export type HttpFile = { + data: Buffer, + name: string +}; + + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +/** + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData; + +/** + * Represents an HTTP request context + */ +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: RequestBody = undefined; + private url: URLParse; + + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = URLParse(url, true); + } + + /* + * Returns the url set in the constructor including the query string + * + */ + public getUrl(): string { + return this.url.toString(); + } + + /** + * Replaces the url set in the constructor with this url. + * + */ + public setUrl(url: string) { + this.url = URLParse(url, true); + } + + /** + * Sets the body of the http request either as a string or FormData + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 + * + * @param body the body of the request + */ + public setBody(body: RequestBody) { + this.body = body; + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): RequestBody { + return this.body; + } + + public setQueryParam(name: string, value: string) { + let queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + } + + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } +} + +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; + } +} + +export interface HttpLibrary { + send(request: RequestContext): Observable; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/http/isomorphic-fetch.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..ed390df7ce10 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/http/isomorphic-fetch.ts @@ -0,0 +1,31 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import { from, Observable } from '../rxjsStub'; +import fetch from "node-fetch"; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + const resultPromise = fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + }).then((resp: any) => { + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; + }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); + }); + + return from>(resultPromise); + + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts new file mode 100644 index 000000000000..965e8fa64649 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts @@ -0,0 +1,11 @@ +import 'es6-promise/auto'; + +export * from './http/http'; +export * from './auth/auth'; +export * from './models/all'; +export { Configuration} from './configuration' +export * from './apis/exception'; +export * from './servers'; + +export { PromiseMiddleware as Middleware } from './middleware'; +export { PetApiAddPetRequest, PetApiDeletePetRequest, PetApiFindPetsByStatusRequest, PetApiFindPetsByTagsRequest, PetApiGetPetByIdRequest, PetApiUpdatePetRequest, PetApiUpdatePetWithFormRequest, PetApiUploadFileRequest, ObjectPetApi as PetApi, StoreApiDeleteOrderRequest, StoreApiGetInventoryRequest, StoreApiGetOrderByIdRequest, StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, UserApiCreateUserRequest, UserApiCreateUsersWithArrayInputRequest, UserApiCreateUsersWithListInputRequest, UserApiDeleteUserRequest, UserApiGetUserByNameRequest, UserApiLoginUserRequest, UserApiLogoutUserRequest, UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/middleware.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/middleware.ts new file mode 100644 index 000000000000..46da5d25ef07 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/middleware.ts @@ -0,0 +1,66 @@ +import {RequestContext, ResponseContext} from './http/http'; +import { Observable, from } from './rxjsStub'; + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Promise; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Promise; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts new file mode 100644 index 000000000000..300b2de4d9a9 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts @@ -0,0 +1,52 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Describes the result of uploading an image resource +*/ +export class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "number", + "format": "int32" + }, + { + "name": "type", + "baseName": "type", + "type": "string", + "format": "" + }, + { + "name": "message", + "baseName": "message", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ApiResponse.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts new file mode 100644 index 000000000000..9b210d5d501d --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts @@ -0,0 +1,45 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A category for a pet +*/ +export class Category { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Category.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject.ts new file mode 100644 index 000000000000..54192c1c8356 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject { + /** + * Updated name of the pet + */ + 'name'?: string; + /** + * Updated status of the pet + */ + 'status'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return InlineObject.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject1.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject1.ts new file mode 100644 index 000000000000..02e988674a08 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/InlineObject1.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject1 { + /** + * Additional data to pass to server + */ + 'additionalMetadata'?: string; + /** + * file to upload + */ + 'file'?: HttpFile; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "additionalMetadata", + "baseName": "additionalMetadata", + "type": "string", + "format": "" + }, + { + "name": "file", + "baseName": "file", + "type": "HttpFile", + "format": "binary" + } ]; + + static getAttributeTypeMap() { + return InlineObject1.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts new file mode 100644 index 000000000000..f485b39e42b3 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts @@ -0,0 +1,240 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './InlineObject'; +export * from './InlineObject1'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + +import { ApiResponse } from './ApiResponse'; +import { Category } from './Category'; +import { InlineObject } from './InlineObject'; +import { InlineObject1 } from './InlineObject1'; +import { Order , OrderStatusEnum } from './Order'; +import { Pet , PetStatusEnum } from './Pet'; +import { Tag } from './Tag'; +import { User } from './User'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + + +let enumsMap: Set = new Set([ + "OrderStatusEnum", + "PetStatusEnum", +]); + +let typeMap: {[index: string]: any} = { + "ApiResponse": ApiResponse, + "Category": Category, + "InlineObject": InlineObject, + "InlineObject1": InlineObject1, + "Order": Order, + "Pet": Pet, + "Tag": Tag, + "User": User, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap.has(expectedType)) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string, format: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } + } else { + if (enumsMap.has(type)) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); + } + return instance; + } + } + + public static deserialize(data: any, type: string, format: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap.has(type)) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); + } + return instance; + } + } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts new file mode 100644 index 000000000000..291018b9e065 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts @@ -0,0 +1,79 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* An order for a pets from the pet store +*/ +export class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; + /** + * Order Status + */ + 'status'?: OrderStatusEnum; + 'complete'?: boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number", + "format": "int64" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number", + "format": "int32" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date", + "format": "date-time" + }, + { + "name": "status", + "baseName": "status", + "type": "OrderStatusEnum", + "format": "" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Order.attributeTypeMap; + } + + public constructor() { + } +} + + +export type OrderStatusEnum = "placed" | "approved" | "delivered" ; + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts new file mode 100644 index 000000000000..77a3490297db --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts @@ -0,0 +1,81 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { Category } from './Category'; +import { Tag } from './Tag'; +import { HttpFile } from '../http/http'; + +/** +* A pet for sale in the pet store +*/ +export class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; + /** + * pet status in the store + */ + 'status'?: PetStatusEnum; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "category", + "baseName": "category", + "type": "Category", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array", + "format": "" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "PetStatusEnum", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Pet.attributeTypeMap; + } + + public constructor() { + } +} + + +export type PetStatusEnum = "available" | "pending" | "sold" ; + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts new file mode 100644 index 000000000000..ce2a0e6d2a80 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts @@ -0,0 +1,45 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A tag for a pet +*/ +export class Tag { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Tag.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts new file mode 100644 index 000000000000..049af95de370 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts @@ -0,0 +1,90 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A User who is purchasing from the pet store +*/ +export class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; + /** + * User Status + */ + 'userStatus'?: number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "username", + "baseName": "username", + "type": "string", + "format": "" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string", + "format": "" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string", + "format": "" + }, + { + "name": "email", + "baseName": "email", + "type": "string", + "format": "" + }, + { + "name": "password", + "baseName": "password", + "type": "string", + "format": "" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string", + "format": "" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return User.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/all.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/all.ts new file mode 100644 index 000000000000..d064eba93abd --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/all.ts @@ -0,0 +1,8 @@ +export * from './ApiResponse' +export * from './Category' +export * from './InlineObject' +export * from './InlineObject1' +export * from './Order' +export * from './Pet' +export * from './Tag' +export * from './User' diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/object_params/package-lock.json new file mode 100644 index 000000000000..69c0e90fc35b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/package-lock.json @@ -0,0 +1,115 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "14.0.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.6.tgz", + "integrity": "sha512-FbNmu4F67d3oZMWBV6Y4MaPER+0EpE9eIYf2yaHhCWovc1dlXCZkqGX4NLHfVVr6umt20TNBdRzrNJIzIKfdbw==" + }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "querystringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "typescript": { + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", + "dev": true + }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + } + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/package.json b/samples/openapi3/client/petstore/typescript/builds/object_params/package.json new file mode 100644 index 000000000000..aaebe4e7687e --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/package.json @@ -0,0 +1,31 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "description": "OpenAPI client for ts-petstore-client", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", + "@types/node": "*", + "form-data": "^2.5.0", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", + "url-parse": "^1.4.3" + }, + "devDependencies": { + "typescript": "^3.9.3" + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/rxjsStub.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/rxjsStub.ts new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts new file mode 100644 index 000000000000..2124324986d7 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts @@ -0,0 +1,47 @@ +import {RequestContext, HttpMethod} from './http/http'; + +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); + } + return replacedUrl + } + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.getUrl() + endpoint, httpMethod); + } +} + +export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json new file mode 100644 index 000000000000..0f376008e1a6 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "module": "commonjs", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "lib": [ "es6" ] + }, + "exclude": [ + "dist", + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObjectParamAPI.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObjectParamAPI.ts new file mode 100644 index 000000000000..10cebbd77dd2 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObjectParamAPI.ts @@ -0,0 +1,442 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { ObservablePetApi } from "./ObservableAPI"; +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; + +export interface PetApiAddPetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiaddPet + */ + pet: Pet +} + +export interface PetApiDeletePetRequest { + /** + * Pet id to delete + * @type number + * @memberof PetApideletePet + */ + petId: number + /** + * + * @type string + * @memberof PetApideletePet + */ + apiKey?: string +} + +export interface PetApiFindPetsByStatusRequest { + /** + * Status values that need to be considered for filter + * @type Array<'available' | 'pending' | 'sold'> + * @memberof PetApifindPetsByStatus + */ + status: Array<'available' | 'pending' | 'sold'> +} + +export interface PetApiFindPetsByTagsRequest { + /** + * Tags to filter by + * @type Array<string> + * @memberof PetApifindPetsByTags + */ + tags: Array +} + +export interface PetApiGetPetByIdRequest { + /** + * ID of pet to return + * @type number + * @memberof PetApigetPetById + */ + petId: number +} + +export interface PetApiUpdatePetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiupdatePet + */ + pet: Pet +} + +export interface PetApiUpdatePetWithFormRequest { + /** + * ID of pet that needs to be updated + * @type number + * @memberof PetApiupdatePetWithForm + */ + petId: number + /** + * Updated name of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + name?: string + /** + * Updated status of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + status?: string +} + +export interface PetApiUploadFileRequest { + /** + * ID of pet to update + * @type number + * @memberof PetApiuploadFile + */ + petId: number + /** + * Additional data to pass to server + * @type string + * @memberof PetApiuploadFile + */ + additionalMetadata?: string + /** + * file to upload + * @type HttpFile + * @memberof PetApiuploadFile + */ + file?: HttpFile +} + + +export class ObjectPetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param param the request object + */ + public addPet(param: PetApiAddPetRequest, options?: Configuration): Promise { + return this.api.addPet(param.pet, options).toPromise(); + } + + /** + * Deletes a pet + * @param param the request object + */ + public deletePet(param: PetApiDeletePetRequest, options?: Configuration): Promise { + return this.api.deletePet(param.petId, param.apiKey, options).toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param param the request object + */ + public findPetsByStatus(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise> { + return this.api.findPetsByStatus(param.status, options).toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param param the request object + */ + public findPetsByTags(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise> { + return this.api.findPetsByTags(param.tags, options).toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param param the request object + */ + public getPetById(param: PetApiGetPetByIdRequest, options?: Configuration): Promise { + return this.api.getPetById(param.petId, options).toPromise(); + } + + /** + * Update an existing pet + * @param param the request object + */ + public updatePet(param: PetApiUpdatePetRequest, options?: Configuration): Promise { + return this.api.updatePet(param.pet, options).toPromise(); + } + + /** + * Updates a pet in the store with form data + * @param param the request object + */ + public updatePetWithForm(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise { + return this.api.updatePetWithForm(param.petId, param.name, param.status, options).toPromise(); + } + + /** + * uploads an image + * @param param the request object + */ + public uploadFile(param: PetApiUploadFileRequest, options?: Configuration): Promise { + return this.api.uploadFile(param.petId, param.additionalMetadata, param.file, options).toPromise(); + } + + +} + + + + +import { ObservableStoreApi } from "./ObservableAPI"; +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; + +export interface StoreApiDeleteOrderRequest { + /** + * ID of the order that needs to be deleted + * @type string + * @memberof StoreApideleteOrder + */ + orderId: string +} + +export interface StoreApiGetInventoryRequest { +} + +export interface StoreApiGetOrderByIdRequest { + /** + * ID of pet that needs to be fetched + * @type number + * @memberof StoreApigetOrderById + */ + orderId: number +} + +export interface StoreApiPlaceOrderRequest { + /** + * order placed for purchasing the pet + * @type Order + * @memberof StoreApiplaceOrder + */ + order: Order +} + + +export class ObjectStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param param the request object + */ + public deleteOrder(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise { + return this.api.deleteOrder(param.orderId, options).toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + * @param param the request object + */ + public getInventory(param: StoreApiGetInventoryRequest, options?: Configuration): Promise<{ [key: string]: number; }> { + return this.api.getInventory( options).toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param param the request object + */ + public getOrderById(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise { + return this.api.getOrderById(param.orderId, options).toPromise(); + } + + /** + * Place an order for a pet + * @param param the request object + */ + public placeOrder(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise { + return this.api.placeOrder(param.order, options).toPromise(); + } + + +} + + + + +import { ObservableUserApi } from "./ObservableAPI"; +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; + +export interface UserApiCreateUserRequest { + /** + * Created user object + * @type User + * @memberof UserApicreateUser + */ + user: User +} + +export interface UserApiCreateUsersWithArrayInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithArrayInput + */ + user: Array +} + +export interface UserApiCreateUsersWithListInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithListInput + */ + user: Array +} + +export interface UserApiDeleteUserRequest { + /** + * The name that needs to be deleted + * @type string + * @memberof UserApideleteUser + */ + username: string +} + +export interface UserApiGetUserByNameRequest { + /** + * The name that needs to be fetched. Use user1 for testing. + * @type string + * @memberof UserApigetUserByName + */ + username: string +} + +export interface UserApiLoginUserRequest { + /** + * The user name for login + * @type string + * @memberof UserApiloginUser + */ + username: string + /** + * The password for login in clear text + * @type string + * @memberof UserApiloginUser + */ + password: string +} + +export interface UserApiLogoutUserRequest { +} + +export interface UserApiUpdateUserRequest { + /** + * name that need to be deleted + * @type string + * @memberof UserApiupdateUser + */ + username: string + /** + * Updated user object + * @type User + * @memberof UserApiupdateUser + */ + user: User +} + + +export class ObjectUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param param the request object + */ + public createUser(param: UserApiCreateUserRequest, options?: Configuration): Promise { + return this.api.createUser(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithArrayInput(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithArrayInput(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithListInput(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithListInput(param.user, options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param param the request object + */ + public deleteUser(param: UserApiDeleteUserRequest, options?: Configuration): Promise { + return this.api.deleteUser(param.username, options).toPromise(); + } + + /** + * Get user by user name + * @param param the request object + */ + public getUserByName(param: UserApiGetUserByNameRequest, options?: Configuration): Promise { + return this.api.getUserByName(param.username, options).toPromise(); + } + + /** + * Logs user into the system + * @param param the request object + */ + public loginUser(param: UserApiLoginUserRequest, options?: Configuration): Promise { + return this.api.loginUser(param.username, param.password, options).toPromise(); + } + + /** + * Logs out current logged in user session + * @param param the request object + */ + public logoutUser(param: UserApiLogoutUserRequest, options?: Configuration): Promise { + return this.api.logoutUser( options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param param the request object + */ + public updateUser(param: UserApiUpdateUserRequest, options?: Configuration): Promise { + return this.api.updateUser(param.username, param.user, options).toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts new file mode 100644 index 000000000000..35d8b2c428f7 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts @@ -0,0 +1,542 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of, from } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class ObservablePetApi { + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public addPet(pet: Pet, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.addPet(pet, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); + })); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); + })); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.findPetsByStatus(status, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); + })); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.findPetsByTags(tags, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); + })); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getPetById(petId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); + })); + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public updatePet(pet: Pet, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updatePet(pet, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); + })); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); + })); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); + })); + } + + +} + + + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class ObservableStoreApi { + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deleteOrder(orderId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); + })); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { + const requestContextPromise = this.requestFactory.getInventory(options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); + })); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getOrderById(orderId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); + })); + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public placeOrder(order: Order, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.placeOrder(order, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); + })); + } + + +} + + + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class ObservableUserApi { + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; + private configuration: Configuration; + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public createUser(user: User, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUser(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithListInput(user: Array, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deleteUser(username, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); + })); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getUserByName(username, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); + })); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.loginUser(username, password, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); + })); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.logoutUser(options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public updateUser(username: string, user: User, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updateUser(username, user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); + })); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts new file mode 100644 index 000000000000..159708737069 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts @@ -0,0 +1,254 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; +import { ObservablePetApi } from './ObservableAPI'; + + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +export class PromisePetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public addPet(pet: Pet, options?: Configuration): Promise { + const result = this.api.addPet(pet, options); + return result.toPromise(); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + const result = this.api.deletePet(petId, apiKey, options); + return result.toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { + const result = this.api.findPetsByStatus(status, options); + return result.toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Promise> { + const result = this.api.findPetsByTags(tags, options); + return result.toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Promise { + const result = this.api.getPetById(petId, options); + return result.toPromise(); + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public updatePet(pet: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(pet, options); + return result.toPromise(); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Promise { + const result = this.api.updatePetWithForm(petId, name, status, options); + return result.toPromise(); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + const result = this.api.uploadFile(petId, additionalMetadata, file, options); + return result.toPromise(); + } + + +} + + + +import { ObservableStoreApi } from './ObservableAPI'; + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +export class PromiseStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Promise { + const result = this.api.deleteOrder(orderId, options); + return result.toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { + const result = this.api.getInventory(options); + return result.toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Promise { + const result = this.api.getOrderById(orderId, options); + return result.toPromise(); + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public placeOrder(order: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(order, options); + return result.toPromise(); + } + + +} + + + +import { ObservableUserApi } from './ObservableAPI'; + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +export class PromiseUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public createUser(user: User, options?: Configuration): Promise { + const result = this.api.createUser(user, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(user, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithListInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(user, options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Promise { + const result = this.api.deleteUser(username, options); + return result.toPromise(); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Promise { + const result = this.api.getUserByName(username, options); + return result.toPromise(); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Promise { + const result = this.api.loginUser(username, password, options); + return result.toPromise(); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Promise { + const result = this.api.logoutUser(options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public updateUser(username: string, user: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, user, options); + return result.toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/util.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/util.ts new file mode 100644 index 000000000000..d1888434535c --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/util.ts @@ -0,0 +1,28 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json index 6760ebac1687..f7f699330c09 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json @@ -1232,10 +1232,6 @@ "url-parse": "^1.4.3" }, "dependencies": { - "@types/isomorphic-fetch": { - "version": "0.0.34", - "bundled": true - }, "@types/node": { "version": "12.12.7", "bundled": true @@ -1259,27 +1255,6 @@ } } }, - "@types/node-fetch": { - "version": "2.5.7", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", - "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", - "requires": { - "@types/node": "*", - "form-data": "^3.0.0" - }, - "dependencies": { - "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - } - } - }, "asynckit": { "version": "0.4.0", "bundled": true @@ -1312,13 +1287,6 @@ "mime-types": "^2.1.12" } }, - "isomorphic-fetch": { - "version": "2.2.1", - "bundled": true, - "requires": { - "whatwg-fetch": ">=0.10.0" - } - }, "mime-db": { "version": "1.40.0", "bundled": true @@ -1343,7 +1311,7 @@ "bundled": true }, "typescript": { - "version": "2.9.2", + "version": "3.9.3", "bundled": true }, "url-parse": { @@ -1353,10 +1321,6 @@ "querystringify": "^2.0.0", "requires-port": "^1.0.0" } - }, - "whatwg-fetch": { - "version": "3.0.0", - "bundled": true } } }, diff --git a/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index fe9df6c67700..956d91e943a8 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -4,7 +4,7 @@ import { expect, assert } from "chai"; import * as fs from 'fs'; const configuration = new petstore.Configuration() -const petApi = new petstore.PromisePetApi(configuration) +const petApi = new petstore.PetApi(configuration) const tag = new petstore.Tag(); tag.name = "tag1" @@ -25,7 +25,7 @@ describe("PetApi", () =>{ }).then((createdPet: petstore.Pet) => { expect(createdPet).to.deep.equal(pet); done() - }).catch((err) => { + }).catch((err: any) => { done(err) }) }) @@ -52,7 +52,7 @@ describe("PetApi", () =>{ }).then((pets: petstore.Pet[]) => { expect(pets.length).to.be.at.least(1); done(); - }).catch((err) => { + }).catch((err: any) => { done(err) }) }) @@ -64,7 +64,7 @@ describe("PetApi", () =>{ }).then((pets: Pet[]) => { expect(pets.length).to.be.at.least(1); done(); - }).catch((err) => { + }).catch((err: any) => { done(err); }) })*/ @@ -75,7 +75,7 @@ describe("PetApi", () =>{ }).then((returnedPet: petstore.Pet) => { expect(returnedPet).to.deep.equal(pet); done(); - }).catch((err) => { + }).catch((err: any) => { done(err); }) }) @@ -87,7 +87,7 @@ describe("PetApi", () =>{ pet.name = updatedName return petApi.updatePet(pet).then(() => { pet.name = oldName; - }).catch((err) => { + }).catch((err: any) => { pet.name = oldName throw err; }); @@ -97,7 +97,7 @@ describe("PetApi", () =>{ expect(returnedPet.id).to.equal(pet.id) expect(returnedPet.name).to.equal(updatedName); done(); - }).catch((err) => { + }).catch((err: any) => { done(err) }) }) @@ -113,7 +113,7 @@ describe("PetApi", () =>{ expect(returnedPet.id).to.equal(pet.id) expect(returnedPet.name).to.equal(updatedName); done() - }).catch((err) => { + }).catch((err: any) => { done(err) }) })*/ @@ -124,7 +124,7 @@ describe("PetApi", () =>{ expect(response.code).to.be.gte(200).and.lt(300); expect(response.message).to.contain("pet.png"); done(); - }).catch((err) => { + }).catch((err: any) => { done(err); }) }) diff --git a/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts index e163cf156bc6..7f5b5dc7c991 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -4,18 +4,6 @@ import { expect} from "chai"; describe("Security Authentication", () => { - describe("No Authentication", () => { - it("No Authentication", () => { - let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); - let noAuth = new petstore.NoAuthentication(); - noAuth.applySecurityAuthentication(ctx); - - expect(ctx.getUrl()).to.equal("http://google.com"); - expect(ctx.getHeaders()).to.deep.equal({}); - expect(ctx.getBody()).to.equal(undefined); - }); - }) - describe("API Key Authentication", () => { // TODO: make all params const variables it("Header API Key", () => { diff --git a/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json index cb57318ae681..d85b9b69d6c7 100644 --- a/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json @@ -4290,7 +4290,6 @@ "version": "file:../../builds/jquery", "requires": { "@types/jquery": "^3.3.29", - "btoa": "^1.2.1", "es6-promise": "^4.2.4", "jquery": "^3.4.1", "url-parse": "^1.4.3" diff --git a/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts index b01b9500b5d1..5ef07e31ed4c 100644 --- a/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts @@ -6,7 +6,7 @@ import * as petstore from 'ts-petstore-client'; import petImage from "./pet.png"; const configuration = new petstore.Configuration() -const petApi = new petstore.PromisePetApi(configuration) +const petApi = new petstore.PetApi(configuration) const tag = new petstore.Tag(); tag.name = "tag1" diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/.gitignore b/samples/openapi3/client/petstore/typescript/tests/object_params/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json new file mode 100644 index 000000000000..a66a373e5ed5 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json @@ -0,0 +1,1416 @@ +{ + "name": "typescript-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", + "dev": true + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=", + "dev": true + }, + "@types/mocha": { + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", + "dev": true + }, + "@types/node": { + "version": "8.10.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", + "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", + "dev": true + }, + "@types/rewire": { + "version": "2.5.28", + "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", + "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" + }, + "acorn": { + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" + } + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" + }, + "ansi-escapes": { + "version": "3.1.0", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "big.js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "requires": { + "callsites": "^0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==" + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "requires": { + "esutils": "^2.0.2" + } + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "enhanced-resolve": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", + "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "object-assign": "^4.0.1", + "tapable": "^0.2.7" + } + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "dev": true, + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "eslint": { + "version": "4.19.1", + "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "requires": { + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", + "table": "4.0.2", + "text-table": "~0.2.0" + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" + }, + "espree": { + "version": "3.5.4", + "resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "external-editor": { + "version": "2.2.0", + "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "requires": { + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", + "write": "^0.2.1" + } + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", + "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" + }, + "json5": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==" + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", + "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==" + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "regexpp": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=" + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "rewire": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/rewire/-/rewire-4.0.1.tgz", + "integrity": "sha512-+7RQ/BYwTieHVXetpKhT11UbfF6v1kGhKFrtZN7UDL2PybMsSt/rpLWeEUGF5Ndsl1D5BxiCB14VDJyoX+noYw==", + "requires": { + "eslint": "^4.19.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "requires": { + "is-promise": "^2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=" + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "requires": { + "rx-lite": "*" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "requires": { + "source-map": "^0.5.6" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + } + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "requires": { + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + }, + "tapable": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", + "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "ts-loader": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.7.tgz", + "integrity": "sha512-8t3bu2FcEkXb+D4L+Cn8qiK2E2C6Ms4/GQChvz6IMbVurcFHLXrhW4EMtfaol1a1ASQACZGDUGit4NHnX9g7hQ==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "enhanced-resolve": "^3.0.0", + "loader-utils": "^1.0.2", + "semver": "^5.0.1" + } + }, + "ts-node": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", + "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", + "requires": { + "arrify": "^1.0.0", + "chalk": "^2.0.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.0", + "tsconfig": "^6.0.0", + "v8flags": "^3.0.0", + "yn": "^2.0.0" + } + }, + "ts-petstore-client": { + "version": "file:../../builds/object_params", + "requires": { + "@types/node": "*", + "@types/node-fetch": "^2.5.7", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", + "form-data": "^2.5.0", + "node-fetch": "^2.6.0", + "url-parse": "^1.4.3" + }, + "dependencies": { + "@types/node": { + "version": "14.0.6", + "bundled": true + }, + "@types/node-fetch": { + "version": "2.5.7", + "bundled": true, + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, + "asynckit": { + "version": "0.4.0", + "bundled": true + }, + "btoa": { + "version": "1.2.1", + "bundled": true + }, + "combined-stream": { + "version": "1.0.8", + "bundled": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "es6-promise": { + "version": "4.2.8", + "bundled": true + }, + "form-data": { + "version": "2.5.1", + "bundled": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "mime-db": { + "version": "1.44.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.27", + "bundled": true, + "requires": { + "mime-db": "1.44.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "bundled": true + }, + "querystringify": { + "version": "2.1.1", + "bundled": true + }, + "requires-port": { + "version": "1.0.0", + "bundled": true + }, + "typescript": { + "version": "3.9.3", + "bundled": true + }, + "url-parse": { + "version": "1.4.7", + "bundled": true, + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "whatwg-fetch": { + "version": "3.0.0", + "bundled": true + } + } + }, + "tsconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", + "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", + "requires": { + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + } + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "v8flags": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", + "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "requires": { + "mkdirp": "^0.5.1" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=" + } + } +} diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/package.json b/samples/openapi3/client/petstore/typescript/tests/object_params/package.json new file mode 100644 index 000000000000..cef97214aee2 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/package.json @@ -0,0 +1,33 @@ +{ + "private": true, + "dependencies": { + "@types/rewire": "^2.5.28", + "form-data": "^2.5.0", + "rewire": "^4.0.1", + "ts-node": "^3.3.0", + "ts-petstore-client": "file:../../builds/object_params" + }, + "scripts": { + "prepublish": "npm install ../../builds/object_params && npm run build", + "test": "mocha test/**/*.ts -r ts-node/register --timeout 10000", + "build": "tsc" + }, + "devDependencies": { + "@types/chai": "^4.0.1", + "@types/isomorphic-fetch": "0.0.34", + "@types/mocha": "^2.2.41", + "@types/node": "^8.10.38", + "chai": "^4.1.0", + "mocha": "^5.2.0", + "ts-loader": "^2.3.0", + "typescript": "^2.4.1" + }, + "name": "typescript-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml b/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml new file mode 100644 index 000000000000..edc01a0776bf --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + org.openapitools + TypeScriptObjectParamsPetstoreClientTests + pom + 1.0-SNAPSHOT + TS Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts new file mode 100644 index 000000000000..d795f643c7ba --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts @@ -0,0 +1,131 @@ +import * as petstore from 'ts-petstore-client' + +import { expect, assert } from "chai"; +import * as fs from 'fs'; + +const configuration = new petstore.Configuration() +const petApi = new petstore.PetApi(configuration) + +const tag = new petstore.Tag(); +tag.name = "tag1" +tag.id = Math.floor(Math.random() * 100000) + +const pet = new petstore.Pet() +pet.id = Math.floor(Math.random() * 100000) +pet.name = "PetName" +pet.photoUrls = [] +pet.status = 'available' +pet.tags = [ tag ] +pet.category = undefined + +describe("PetApi", () =>{ + it("addPet", (done) => { + petApi.addPet({ pet: pet }).then(() => { + return petApi.getPetById({ petId: pet.id }) + }).then((createdPet: petstore.Pet) => { + expect(createdPet).to.deep.equal(pet); + done() + }).catch((err: any) => { + done(err) + }) + }) + + it("deletePet", (done) => { + petApi.addPet({pet: pet}).then(() => { + return petApi.deletePet({ petId: pet.id} ) + }).then(() => { + return petApi.getPetById({ petId: pet.id }) + }).then((pet: petstore.Pet) => { + done("Pet with id " + pet.id + " was not deleted!"); + }).catch((err: any) => { + if (err.code && err.code == 404) { + done(); + } else { + done(err) + } + }) + }) + + it("findPetsByStatus", (done) => { + petApi.addPet({ pet: pet}).then(() => { + return petApi.findPetsByStatus({ status: ["available"]}) + }).then((pets: petstore.Pet[]) => { + expect(pets.length).to.be.at.least(1); + done(); + }).catch((err: any) => { + done(err) + }) + }) + + // bugged on server side! Code 500 +/* it("findPetsByTag", (done) => { + petApi.addPet(pet).then(() => { + return petApi.findPetsByTags([tag.name]) + }).then((pets: Pet[]) => { + expect(pets.length).to.be.at.least(1); + done(); + }).catch((err: any) => { + done(err); + }) + })*/ + + it("getPetById", (done) => { + petApi.addPet({pet: pet}).then(() => { + return petApi.getPetById({ petId: pet.id}) + }).then((returnedPet: petstore.Pet) => { + expect(returnedPet).to.deep.equal(pet); + done(); + }).catch((err: any) => { + done(err); + }) + }) + + it("updatePet", (done) => { + const oldName = pet.name + const updatedName = "updated name"; + petApi.addPet({pet: pet}).then(() => { + pet.name = updatedName + return petApi.updatePet({pet: pet}).then(() => { + pet.name = oldName; + }).catch((err: any) => { + pet.name = oldName + throw err; + }); + }).then(() => { + return petApi.getPetById({ petId: pet.id }); + }).then((returnedPet: petstore.Pet) => { + expect(returnedPet.id).to.equal(pet.id) + expect(returnedPet.name).to.equal(updatedName); + done(); + }).catch((err: any) => { + done(err) + }) + }) + +// not supported by online swagger api? +/* it("updatePetWithForm", (done) => { + const updatedName = "updated name"; + petApi.addPet(pet).then(() => { + return petApi.updatePetWithForm(pet.id, updatedName) + }).then(() => { + return petApi.getPetById(pet.id) + }).then((returnedPet: Pet) => { + expect(returnedPet.id).to.equal(pet.id) + expect(returnedPet.name).to.equal(updatedName); + done() + }).catch((err: any) => { + done(err) + }) + })*/ + + it("uploadFile", (done) => { + const image = fs.readFileSync(__dirname + "/pet.png") + petApi.uploadFile({ petId: pet.id, additionalMetadata: "Metadata", file: { name: "pet.png", data: image}}).then((response: any) => { + expect(response.code).to.be.gte(200).and.lt(300); + expect(response.message).to.contain("pet.png"); + done(); + }).catch((err: any) => { + done(err); + }) + }) +}) \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/pet.png b/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/pet.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a9c49163db88f92e798e1c2aa4920ee6190829 GIT binary patch literal 1122 zcmV-o1fBbdP)Pv>k;Jhr>-0WM zqfHxc(XJkZAh2f0;gAyF_nm#aN+~I&5JCvSdygNrRv`otbzNtS>AFs9t+kd?a?T%* z)A#7L)>>=MIfSsT>+N=1*LB-A5GbWmN`2o8Avot!O8oc*!M^V~=NO~+exB!Pnm~|q zCL*nM&UxQ=B9c;K=bS%s{33&8S(arvpU=y(AOmad>+35KS!W+5c8t}76wlv2uV+qP|sF_u#B{a1pN5)la@o}qyrW6U{w@3(CWA;cI_WK=ch zTuQ06g5V1dV~k2Eob!F(rIe4d06nGTy@zw=d0y8QOr;beGREZlLO(rs6>Zz5lu}AD z#-J6{#4&&_%i_I9m&F)kjGS{sopWxu&-yUNXrAY;>ku*$-1i-^LvD1y^?IG>IfSrn zTT1CMl#~*%ng*W;VCtN+F@}g>%~sOu^?E*^=Xpl>>$;|t5H%4!;tC;-GkAZ0AIH%- zmve@NODWBim&*msb-7&N&YUwW)O3fowbp-TugAj{=f)Uo?KqCZFuc6H48t%CgSGbgGGL5R z2tf#e*?{wiw>1$Fp?dHo5fPDd?sPi6y}f}zYmJf|5CFHSeBQE5_0x-rt=4g|TbKZ3w z4AX`Ox)hbvTKD(moa_4@lt}J?0NP0@@loIR2p?%ddfd9`ENgAob#SLK#yNL**Z(De zENB^H4DP=M*EkTn5CYE=M2%C2{q?B^_zuSqpi;_O3sA-w^u-N>#}AIQ2>yl67$fH# zo-}Aq?6}178_@09({S!_n_SH&_zh5eBkt=b(0^-yCcu4wkgc_N79w7N z!cJ}f;iA*&gpNhLz-5fVR89SMq5gJJ*L9c>=p(c{+OkRUf6yNUecxly!!t;t$@0BJ oenc<~0|qjrfO8I?vH!RJ0MkcqZO@AHAOHXW07*qoM6N<$f;dkN^Z)<= literal 0 HcmV?d00001 diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/tsconfig.json b/samples/openapi3/client/petstore/typescript/tests/object_params/tsconfig.json new file mode 100644 index 000000000000..4596f6e40bcf --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha", + "node" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} From fbed6ca418b1879f56048ad03212c5d993c04292 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Mon, 1 Jun 2020 23:46:29 +0200 Subject: [PATCH 79/85] Upgrade typescript docs --- docs/generators/typescript.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index ed96edc9c4ae..f35302a1652d 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -20,6 +20,7 @@ sidebar_label: typescript |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| +|useObjectParameters|useObjectParameters| |false| |useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false| ## IMPORT MAPPING From 4258a17a7642956b3ee31b423a052e1c58b57740 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 3 Jun 2020 22:05:47 +0200 Subject: [PATCH 80/85] Updated generators --- docs/generators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/generators.md b/docs/generators.md index 7a413bd2db3e..620875c39aff 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -15,7 +15,6 @@ The following generators are available: * [cpp-qt5-client](generators/cpp-qt5-client.md) * [cpp-restsdk](generators/cpp-restsdk.md) * [cpp-tizen](generators/cpp-tizen.md) -* [cpp-ue4 (beta)](generators/cpp-ue4.md) * [csharp](generators/csharp.md) * [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2.md) * [csharp-netcore](generators/csharp-netcore.md) @@ -105,6 +104,7 @@ The following generators are available: * [kotlin-spring](generators/kotlin-spring.md) * [kotlin-vertx (beta)](generators/kotlin-vertx.md) * [nodejs-express-server (beta)](generators/nodejs-express-server.md) +* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated.md) * [php-laravel](generators/php-laravel.md) * [php-lumen](generators/php-lumen.md) * [php-silex-deprecated (deprecated)](generators/php-silex-deprecated.md) From 8fc7eebbb4fb316a391077ba5f61b0b5db17bc8d Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Wed, 3 Jun 2020 22:06:52 +0200 Subject: [PATCH 81/85] Updated samples --- .../builds/default/.openapi-generator/FILES | 32 +++++++++++++++++++ .../builds/jquery/.openapi-generator/FILES | 32 +++++++++++++++++++ .../object_params/.openapi-generator/FILES | 32 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/FILES create mode 100644 samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/FILES create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/FILES diff --git a/samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/FILES new file mode 100644 index 000000000000..d21a391e0080 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/default/.openapi-generator/FILES @@ -0,0 +1,32 @@ +.gitignore +README.md +apis/PetApi.ts +apis/StoreApi.ts +apis/UserApi.ts +apis/baseapi.ts +apis/exception.ts +auth/auth.ts +configuration.ts +git_push.sh +http/http.ts +http/isomorphic-fetch.ts +index.ts +middleware.ts +models/ApiResponse.ts +models/Category.ts +models/InlineObject.ts +models/InlineObject1.ts +models/ObjectSerializer.ts +models/Order.ts +models/Pet.ts +models/Tag.ts +models/User.ts +models/all.ts +package.json +rxjsStub.ts +servers.ts +tsconfig.json +types/ObjectParamAPI.ts +types/ObservableAPI.ts +types/PromiseAPI.ts +util.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/FILES new file mode 100644 index 000000000000..71820af41a4f --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/.openapi-generator/FILES @@ -0,0 +1,32 @@ +.gitignore +README.md +apis/PetApi.ts +apis/StoreApi.ts +apis/UserApi.ts +apis/baseapi.ts +apis/exception.ts +auth/auth.ts +configuration.ts +git_push.sh +http/http.ts +http/jquery.ts +index.ts +middleware.ts +models/ApiResponse.ts +models/Category.ts +models/InlineObject.ts +models/InlineObject1.ts +models/ObjectSerializer.ts +models/Order.ts +models/Pet.ts +models/Tag.ts +models/User.ts +models/all.ts +package.json +rxjsStub.ts +servers.ts +tsconfig.json +types/ObjectParamAPI.ts +types/ObservableAPI.ts +types/PromiseAPI.ts +util.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/FILES new file mode 100644 index 000000000000..d21a391e0080 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/.openapi-generator/FILES @@ -0,0 +1,32 @@ +.gitignore +README.md +apis/PetApi.ts +apis/StoreApi.ts +apis/UserApi.ts +apis/baseapi.ts +apis/exception.ts +auth/auth.ts +configuration.ts +git_push.sh +http/http.ts +http/isomorphic-fetch.ts +index.ts +middleware.ts +models/ApiResponse.ts +models/Category.ts +models/InlineObject.ts +models/InlineObject1.ts +models/ObjectSerializer.ts +models/Order.ts +models/Pet.ts +models/Tag.ts +models/User.ts +models/all.ts +package.json +rxjsStub.ts +servers.ts +tsconfig.json +types/ObjectParamAPI.ts +types/ObservableAPI.ts +types/PromiseAPI.ts +util.ts From 0906e3cbb594983abc1ccdfed6947daa3f214cd4 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 4 Jun 2020 01:09:55 +0200 Subject: [PATCH 82/85] Updated docs --- docs/generators.md | 2 +- docs/generators/typescript.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/generators.md b/docs/generators.md index 620875c39aff..7a413bd2db3e 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -15,6 +15,7 @@ The following generators are available: * [cpp-qt5-client](generators/cpp-qt5-client.md) * [cpp-restsdk](generators/cpp-restsdk.md) * [cpp-tizen](generators/cpp-tizen.md) +* [cpp-ue4 (beta)](generators/cpp-ue4.md) * [csharp](generators/csharp.md) * [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2.md) * [csharp-netcore](generators/csharp-netcore.md) @@ -104,7 +105,6 @@ The following generators are available: * [kotlin-spring](generators/kotlin-spring.md) * [kotlin-vertx (beta)](generators/kotlin-vertx.md) * [nodejs-express-server (beta)](generators/nodejs-express-server.md) -* [nodejs-server-deprecated (deprecated)](generators/nodejs-server-deprecated.md) * [php-laravel](generators/php-laravel.md) * [php-lumen](generators/php-lumen.md) * [php-silex-deprecated (deprecated)](generators/php-silex-deprecated.md) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index f35302a1652d..919faccc73e1 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -6,6 +6,8 @@ sidebar_label: typescript | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|disallowAdditionalPropertiesIfNotPresent|Specify the behavior when the 'additionalProperties' keyword is not present in the OAS document +If false: the 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. If true: when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.This setting is currently ignored for OAS 2.0 documents: 1) When the 'additionalProperties' keyword is not present in a 2.0 schema, additional properties are NOT allowed. 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed.Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.
|true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)| |Buffer| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| From bf2b05defa79aaddaac06801c4e166c95d439ccd Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Thu, 4 Jun 2020 21:54:39 +0200 Subject: [PATCH 83/85] Readded pom.xml --- .../typescript/builds/object_params/pom.xml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 samples/openapi3/client/petstore/typescript/builds/object_params/pom.xml diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/pom.xml b/samples/openapi3/client/petstore/typescript/builds/object_params/pom.xml new file mode 100644 index 000000000000..7eac981b3f45 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + org.openapitools + TypeScriptBuildObjectParamsPetstoreClientSample + pom + 1.0-SNAPSHOT + TS Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-build + pre-integration-test + + exec + + + npm + + run + build + + + + + + + + From 4608264a12096ba11698a7aaf4d076f4621a0a8f Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Sat, 13 Jun 2020 21:26:08 +0200 Subject: [PATCH 84/85] [Typescript] Support InversifyJS (#6489) * Add config option to enable InversifyJS * Add pascal case lambda for mustache * Generate a class for each auth method * Add service identifiers and service binder helper * Split Configuration into interface and factory This way we don't need to import the factory everywhere to do typechecking. * Define minimal interface for ServerConfiguration * Add annotations for inversify when enabled * Always expose list of server configurations * Add samples and defalt tests for useInversify * Simplify sample generation script * Fix: Add object_params arg description to help * Fix: Properly enable inversify with bool property * Build tests in pom instead of prepublish Otherwise running `npm install`, when the build failed was impossible. * Update dependencies for inversify tests * Test basic api service resolution * Remove Promise and Observable prefix from exports * Fix, RxJS: Import Observable in object params api * Add ioc service identifier for object param api * Add hint about unimpeded development * Simplify api service binder syntax * Remove default tests for inversify * Add wrapper for easy promise based http libraries This wrapper allows defining and injecting http libraries that do not need to know anything about observables, especially when useRxJS is not enabled. I will employ this in the tests for InversifyJS. Not sure if we should also use this wrapper internally. * Add named injects for remaining auth parameters * Directly inject promise services without RxJS * Add tests for api service binder * Add convenience method to bind all api services * Fix: Rename inversify test artifact * Run bin/utils/copy-to-website.sh --- .travis.yml | 1 + CONTRIBUTING.md | 1 + bin/typescript.sh | 23 +- bin/windows/typescript.bat | 15 +- docs/contributing.md | 1 + docs/generators/typescript.md | 3 +- .../openapitools/codegen/DefaultCodegen.java | 3 +- .../languages/TypeScriptClientCodegen.java | 30 +- .../templating/mustache/CamelCaseLambda.java | 9 +- .../resources/typescript/api/api.mustache | 9 + .../resources/typescript/api/baseapi.mustache | 9 +- .../resources/typescript/auth/auth.mustache | 219 ++- .../typescript/configuration.mustache | 90 +- .../resources/typescript/http/http.mustache | 14 +- .../typescript/http/servers.mustache | 10 +- .../main/resources/typescript/index.mustache | 31 +- .../resources/typescript/package.mustache | 5 +- .../services/ObjectParamAPI.mustache | 35 + .../services/ObservableAPI.mustache | 23 + .../typescript/services/PromiseAPI.mustache | 22 + .../typescript/services/api.mustache | 23 + .../services/configuration.mustache | 21 + .../typescript/services/http.mustache | 20 + .../typescript/services/index.mustache | 165 ++ .../resources/typescript/tsconfig.mustache | 8 +- .../typescript/types/ObjectParamAPI.mustache | 3 + .../typescript/types/ObservableAPI.mustache | 42 +- .../typescript/types/PromiseAPI.mustache | 26 +- pom.xml | 2 + .../typescript/builds/default/auth/auth.ts | 156 +- .../builds/default/configuration.ts | 88 +- .../typescript/builds/default/http/http.ts | 14 +- .../typescript/builds/default/index.ts | 15 +- .../typescript/builds/default/servers.ts | 10 +- .../typescript/builds/default/tsconfig.json | 3 +- .../builds/default/types/ObservableAPI.ts | 60 +- .../builds/default/types/PromiseAPI.ts | 30 +- .../typescript/builds/inversify/.gitignore | 1 + .../inversify/.openapi-generator-ignore | 23 + .../builds/inversify/.openapi-generator/FILES | 41 + .../inversify/.openapi-generator/VERSION | 1 + .../typescript/builds/inversify/README.md | 30 + .../builds/inversify/apis/PetApi.service.ts | 44 + .../builds/inversify/apis/PetApi.ts | 653 ++++++++ .../builds/inversify/apis/StoreApi.service.ts | 27 + .../builds/inversify/apis/StoreApi.ts | 298 ++++ .../builds/inversify/apis/UserApi.service.ts | 43 + .../builds/inversify/apis/UserApi.ts | 590 +++++++ .../builds/inversify/apis/baseapi.ts | 40 + .../builds/inversify/apis/exception.ts | 14 + .../typescript/builds/inversify/auth/auth.ts | 115 ++ .../builds/inversify/configuration.ts | 66 + .../typescript/builds/inversify/git_push.sh | 52 + .../typescript/builds/inversify/http/http.ts | 206 +++ .../builds/inversify/http/isomorphic-fetch.ts | 31 + .../typescript/builds/inversify/index.ts | 14 + .../typescript/builds/inversify/middleware.ts | 66 + .../builds/inversify/models/ApiResponse.ts | 52 + .../builds/inversify/models/Category.ts | 45 + .../builds/inversify/models/InlineObject.ts | 48 + .../builds/inversify/models/InlineObject1.ts | 48 + .../inversify/models/ObjectSerializer.ts | 240 +++ .../builds/inversify/models/Order.ts | 79 + .../typescript/builds/inversify/models/Pet.ts | 81 + .../typescript/builds/inversify/models/Tag.ts | 45 + .../builds/inversify/models/User.ts | 90 + .../typescript/builds/inversify/models/all.ts | 8 + .../builds/inversify/package-lock.json | 120 ++ .../typescript/builds/inversify/package.json | 32 + .../typescript/builds/inversify/pom.xml | 60 + .../typescript/builds/inversify/rxjsStub.ts | 27 + .../typescript/builds/inversify/servers.ts | 53 + .../inversify/services/ObjectParamAPI.ts | 153 ++ .../inversify/services/ObservableAPI.ts | 64 + .../builds/inversify/services/PromiseAPI.ts | 63 + .../inversify/services/configuration.ts | 21 + .../builds/inversify/services/http.ts | 17 + .../builds/inversify/services/index.ts | 126 ++ .../typescript/builds/inversify/tsconfig.json | 31 + .../builds/inversify/types/ObjectParamAPI.ts | 442 +++++ .../builds/inversify/types/ObservableAPI.ts | 565 +++++++ .../builds/inversify/types/PromiseAPI.ts | 277 +++ .../typescript/builds/inversify/util.ts | 28 + .../typescript/builds/jquery/auth/auth.ts | 156 +- .../typescript/builds/jquery/configuration.ts | 88 +- .../typescript/builds/jquery/http/http.ts | 14 +- .../typescript/builds/jquery/index.ts | 15 +- .../builds/jquery/package-lock.json | 5 - .../typescript/builds/jquery/servers.ts | 10 +- .../typescript/builds/jquery/tsconfig.json | 3 +- .../builds/jquery/types/ObservableAPI.ts | 60 +- .../builds/jquery/types/PromiseAPI.ts | 30 +- .../builds/object_params/auth/auth.ts | 156 +- .../builds/object_params/configuration.ts | 88 +- .../builds/object_params/http/http.ts | 14 +- .../typescript/builds/object_params/index.ts | 15 +- .../builds/object_params/servers.ts | 10 +- .../builds/object_params/tsconfig.json | 3 +- .../object_params/types/ObservableAPI.ts | 60 +- .../builds/object_params/types/PromiseAPI.ts | 30 +- .../tests/default/package-lock.json | 68 +- .../typescript/tests/default/package.json | 1 - .../petstore/typescript/tests/default/pom.xml | 14 + .../tests/default/test/api/PetApi.test.ts | 2 +- .../tests/default/test/auth/auth.test.ts | 31 +- .../typescript/tests/inversify/.gitignore | 1 + .../tests/inversify/package-lock.json | 1490 +++++++++++++++++ .../typescript/tests/inversify/package.json | 34 + .../typescript/tests/inversify/pom.xml | 73 + .../tests/inversify/test/services.test.ts | 139 ++ .../typescript/tests/inversify/tsconfig.json | 20 + .../typescript/tests/jquery/package-lock.json | 129 +- .../tests/jquery/test/api/PetApi.test.ts | 2 +- .../tests/object_params/package-lock.json | 48 +- .../tests/object_params/package.json | 1 - .../typescript/tests/object_params/pom.xml | 14 + .../object_params/test/api/PetApi.test.ts | 3 +- 117 files changed, 8354 insertions(+), 882 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/ObjectParamAPI.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/ObservableAPI.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/PromiseAPI.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/api.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/configuration.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/http.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/services/index.mustache create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/.gitignore create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator-ignore create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/VERSION create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/README.md create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.service.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.service.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.service.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/apis/exception.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/configuration.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/git_push.sh create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/http/http.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/http/isomorphic-fetch.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/index.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/middleware.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject1.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/models/all.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/package-lock.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/package.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/pom.xml create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/rxjsStub.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/servers.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/ObjectParamAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/ObservableAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/PromiseAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/configuration.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/http.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/services/index.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/types/ObjectParamAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts create mode 100644 samples/openapi3/client/petstore/typescript/builds/inversify/util.ts create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/.gitignore create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/package-lock.json create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/package.json create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/pom.xml create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/test/services.test.ts create mode 100644 samples/openapi3/client/petstore/typescript/tests/inversify/tsconfig.json diff --git a/.travis.yml b/.travis.yml index 0811dd6e114d..3ce2f9412241 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ cache: - $HOME/samples/openapi3/client/petstore/typescript/tests/default/node_modules - $HOME/samples/openapi3/client/petstore/typescript/tests/jquery/node_modules - $HOME/samples/openapi3/client/petstore/typescript/tests/object_params/node_modules + - $HOME/samples/openapi3/client/petstore/typescript/tests/inversify/node_modules - $HOME/samples/client/petstore/typescript-node/npm/node_modules - $HOME/samples/client/petstore/typescript-node/npm/typings/ - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dcce5cb60987..e701fb5ba33a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,6 +86,7 @@ To add test cases (optional) covering the change in the code generator, please r To test the templates, please perform the following: - Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. - Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) diff --git a/bin/typescript.sh b/bin/typescript.sh index 346724c00268..3cde7ff06169 100755 --- a/bin/typescript.sh +++ b/bin/typescript.sh @@ -19,6 +19,8 @@ if [ ! -d "${APP_DIR}" ]; then fi executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" +common_args="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript" +samples="samples/openapi3/client/petstore/typescript/builds" if [ ! -f "$executable" ] then @@ -27,16 +29,19 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -echo "Creating default (fetch) client!" -ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/default --additional-properties=platform=node,npmName=ts-petstore-client $@" -java $JAVA_OPTS -jar $executable $ags -echo "Creating jquery client!" -ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" +printf "\033[32m## Creating default (fetch) client!\033[0m\n" +args="-o $samples/default --additional-properties=platform=node,npmName=ts-petstore-client $@" +java $JAVA_OPTS -jar $executable $common_args $args -java $JAVA_OPTS -jar $executable $ags +printf "\033[32m## Creating jquery client!\033[0m\n" +args="-o $samples/jquery --additional-properties=framework=jquery,npmName=ts-petstore-client $@" +java $JAVA_OPTS -jar $executable $common_args $args -echo "Creating fetch object client!" -ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript -o samples/openapi3/client/petstore/typescript/builds/object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters $@" +printf "\033[32m## Creating fetch object client!\033[0m\n" +args="-o $samples/object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters=true $@" +java $JAVA_OPTS -jar $executable $common_args $args -java $JAVA_OPTS -jar $executable $ags +printf "\033[32m## Creating fetch client with InversifyJS support!\033[0m\n" +args="-o $samples/inversify --additional-properties=platform=node,npmName=ts-petstore-client,useInversify=true $@" +java $JAVA_OPTS -jar $executable $common_args $args diff --git a/bin/windows/typescript.bat b/bin/windows/typescript.bat index fe4dae009466..a6e13ff45396 100755 --- a/bin/windows/typescript.bat +++ b/bin/windows/typescript.bat @@ -6,11 +6,14 @@ If Not Exist %executable% ( REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\default --additional-properties=platform=node,npmName=ts-petstore-client -java %JAVA_OPTS% -jar %executable% %ags% +set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\default --additional-properties=platform=node,npmName=ts-petstore-client +java %JAVA_OPTS% -jar %executable% %args% -ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\jquery --additional-properties=framework=jquery,npmName=ts-petstore-client -java %JAVA_OPTS% -jar %executable% %ags% +args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\jquery --additional-properties=framework=jquery,npmName=ts-petstore-client +java %JAVA_OPTS% -jar %executable% %args% -set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters -java %JAVA_OPTS% -jar %executable% %ags% +set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\object_params --additional-properties=platform=node,npmName=ts-petstore-client,useObjectParameters +java %JAVA_OPTS% -jar %executable% %args% + +set args=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g typescript -o samples\openapi3\client\petstore\typescript\builds\inversify --additional-properties=platform=node,npmName=ts-petstore-client,useInversify +java %JAVA_OPTS% -jar %executable% %args% diff --git a/docs/contributing.md b/docs/contributing.md index 69b766b2e88c..f7182f3a21f1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -90,6 +90,7 @@ To add test cases (optional) covering the change in the code generator, please r To test the templates, please perform the following: - Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. - Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 919faccc73e1..80072408e8e9 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -22,7 +22,8 @@ If false: the 'additionalProperties' implementation is compliant with the OAS an |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| -|useObjectParameters|useObjectParameters| |false| +|useInversify|Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container.| |false| +|useObjectParameters|Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.| |false| |useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false| ## IMPORT MAPPING diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index b585d0d42176..13d58623f21f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -361,7 +361,8 @@ protected ImmutableMap.Builder addMustacheLambdas() { .put("lowercase", new LowercaseLambda().generator(this)) .put("uppercase", new UppercaseLambda()) .put("titlecase", new TitlecaseLambda()) - .put("camelcase", new CamelCaseLambda().generator(this)) + .put("camelcase", new CamelCaseLambda(true).generator(this)) + .put("pascalcase", new CamelCaseLambda(false).generator(this)) .put("indented", new IndentedLambda()) .put("indented_8", new IndentedLambda(8, " ")) .put("indented_12", new IndentedLambda(12, " ")) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 1b3517c5fae4..2ae19df974fc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -56,6 +56,8 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser) / Buffer (node)"; private static final String USE_RXJS_SWITCH = "useRxJS"; private static final String USE_RXJS_SWITCH_DESC = "Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework."; + private static final String USE_INVERSIFY_SWITCH = "useInversify"; + private static final String USE_INVERSIFY_SWITCH_DESC = "Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container."; private static final String USE_OBJECT_PARAMS_SWITCH = "useObjectParameters"; private static final String USE_OBJECT_PARAMS_DESC = "Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument."; @@ -167,7 +169,8 @@ public TypeScriptClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false")); cliOptions.add(new CliOption(TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE, TypeScriptClientCodegen.FILE_CONTENT_DATA_TYPE_DESC).defaultValue("Buffer")); cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false")); - cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH, TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH).defaultValue("false")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH, TypeScriptClientCodegen.USE_OBJECT_PARAMS_DESC).defaultValue("false")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_INVERSIFY_SWITCH, TypeScriptClientCodegen.USE_INVERSIFY_SWITCH_DESC).defaultValue("false")); CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { @@ -208,15 +211,15 @@ public TypeScriptClientCodegen() { supportingFiles.add(new SupportingFile("types" + File.separator + "ObjectParamAPI.mustache", "types", "ObjectParamAPI.ts")); // models - this.setModelPackage(""); + setModelPackage(""); supportingFiles.add(new SupportingFile("model" + File.separator + "ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); modelTemplateFiles.put("model" + File.separator + "model.mustache", ".ts"); // api - this.setApiPackage(""); + setApiPackage(""); supportingFiles.add(new SupportingFile("api" + File.separator + "middleware.mustache", "", "middleware.ts")); - this.supportingFiles.add(new SupportingFile("api" + File.separator + "baseapi.mustache", "apis", "baseapi.ts")); - this.apiTemplateFiles.put("api" + File.separator + "api.mustache", ".ts"); + supportingFiles.add(new SupportingFile("api" + File.separator + "baseapi.mustache", "apis", "baseapi.ts")); + apiTemplateFiles.put("api" + File.separator + "api.mustache", ".ts"); } public String getNpmName() { @@ -791,7 +794,18 @@ public void processOpts() { final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH); if (!useRxJS) { - supportingFiles.add(new SupportingFile("rxjsStub.mustache", "rxjsStub.ts")); + supportingFiles.add(new SupportingFile("rxjsStub.mustache", "rxjsStub.ts")); + } + + final boolean useInversify = convertPropertyToBooleanAndWriteBack(USE_INVERSIFY_SWITCH); + if (useInversify) { + supportingFiles.add(new SupportingFile("services" + File.separator + "index.mustache", "services", "index.ts")); + supportingFiles.add(new SupportingFile("services" + File.separator + "configuration.mustache", "services", "configuration.ts")); + supportingFiles.add(new SupportingFile("services" + File.separator + "PromiseAPI.mustache", "services", "PromiseAPI.ts")); + supportingFiles.add(new SupportingFile("services" + File.separator + "ObservableAPI.mustache", "services", "ObservableAPI.ts")); + supportingFiles.add(new SupportingFile("services" + File.separator + "ObjectParamAPI.mustache", "services", "ObjectParamAPI.ts")); + supportingFiles.add(new SupportingFile("services" + File.separator + "http.mustache", "services", "http.ts")); + apiTemplateFiles.put("services" + File.separator + "api.mustache", ".service.ts"); } // NPM Settings @@ -806,10 +820,6 @@ public void processOpts() { if (additionalProperties.containsKey(NPM_REPOSITORY)) { setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); } - - - - } private String getHttpLibForFramework(String object) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java index 32f62042c957..cf2f2571dc38 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CamelCaseLambda.java @@ -42,11 +42,14 @@ public class CamelCaseLambda implements Mustache.Lambda { private CodegenConfig generator = null; private Boolean escapeParam = false; + private Boolean lowercaseFirstLetter = true; - public CamelCaseLambda() { - + public CamelCaseLambda(boolean lowercaseFirstLetter) { + this.lowercaseFirstLetter = lowercaseFirstLetter; } + public CamelCaseLambda() {} + public CamelCaseLambda generator(final CodegenConfig generator) { this.generator = generator; return this; @@ -59,7 +62,7 @@ public CamelCaseLambda escapeAsParamName(final Boolean escape) { @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { - String text = camelize(fragment.execute(), true); + String text = camelize(fragment.execute(), lowercaseFirstLetter); if (generator != null) { text = generator.sanitizeName(text); if (generator.reservedWords().contains(text)) { diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index 17d64ecfd22c..e4bb60616ff2 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -10,6 +10,9 @@ import * as FormData from "form-data"; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; +{{#useInversify}} +import { injectable } from "inversify"; +{{/useInversify}} {{#imports}} import { {{classname}} } from '..{{filename}}'; @@ -19,6 +22,9 @@ import { {{classname}} } from '..{{filename}}'; /** * {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}} */ +{{#useInversify}} +@injectable() +{{/useInversify}} export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#operation}} @@ -142,6 +148,9 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#operations}} +{{#useInversify}} +@injectable() +{{/useInversify}} export class {{classname}}ResponseProcessor { {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache b/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache index fe7ee3d15118..545fe4aacffc 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache @@ -1,4 +1,8 @@ import { Configuration } from '../configuration' +{{#useInversify}} +import { injectable, inject } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; +{{/useInversify}} /** * @@ -17,9 +21,12 @@ export const COLLECTION_FORMATS = { * @export * @class BaseAPI */ +{{#useInversify}} +@injectable() +{{/useInversify}} export class BaseAPIRequestFactory { - constructor(protected configuration: Configuration) { + constructor({{#useInversify}}@inject(AbstractConfiguration) {{/useInversify}}protected configuration: Configuration) { } }; diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 261f70b3226b..8e8d33d86d35 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -1,4 +1,3 @@ -import {RequestContext} from '../http/http'; // typings for btoa are incorrect {{#platforms}} {{#node}} @@ -6,135 +5,127 @@ import {RequestContext} from '../http/http'; import * as btoa from "btoa"; {{/node}} {{/platforms}} -/** - * Base class for all authentication schemes. - * - */ -export abstract class SecurityAuthentication { - - public constructor(private name: string) { - - } - - /* - * - * @return returns the name of the security authentication as specified in OAI - */ - public getName(): string { - return this.name; - } - - /** - * Applies the authentication scheme to the request context - * - * @params context the request context which should use this authentication scheme - */ - public abstract applySecurityAuthentication(context: RequestContext): void | Promise; - -} +import { RequestContext } from "../http/http"; +{{#useInversify}} +import { injectable, inject, named } from "inversify"; +import { AbstractTokenProvider } from "../services/configuration"; +{{/useInversify}} /** - * Applies an api key to the request context. - * + * Interface authentication schemes. */ -export class APIKeyAuthentication extends SecurityAuthentication { - - /** - * Configures this api key authentication with the necessary properties - * - * @param authName: name of this authentication scheme as specified in the swagger.json - * @param paramName: Parameter name used for the api key - * @param keyLocation: Parameter location, either query, header or cookie. - * @param apiKey: The api key to be used for every request - */ - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - if (this.keyLocation === "header") { - context.setHeaderParam(this.paramName, this.apiKey); - } else if (this.keyLocation === "cookie") { - context.addCookie(this.paramName, this.apiKey); - } else if (this.keyLocation === "query") { - context.setQueryParam(this.paramName, this.apiKey); - } - } -} - +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; -/** - * Applies basic http authentication to a request. - * - */ -export class HttpBasicAuthentication extends SecurityAuthentication { - - /** - * Configures the http authentication with the required details. - * - * - * @param authName name of the authentication scheme as defined in swagger json - * @param username username for http basic authentication - * @param password password for http basic authentication - */ - public constructor(authName: string, private username: string, private password: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - let comb = this.username + ":" + this.password; - context.setHeaderParam("Authorization", "Basic " + btoa(comb)); - } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; } +{{#useInversify}} +export const AuthApiKey = Symbol("auth.api_key"); +export const AuthUsername = Symbol("auth.username"); +export const AuthPassword = Symbol("auth.password"); + +{{/useInversify}} export interface TokenProvider { getToken(): Promise | string; } +{{#authMethods}} /** - * Applies http bearer authentication to a request. - * + * Applies {{type}} authentication to the request context. */ -export class HttpBearerAuthentication extends SecurityAuthentication { +{{#useInversify}} +@injectable() +{{/useInversify}} +export class {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication implements SecurityAuthentication { + {{#isApiKey}} + /** + * Configures this api key authentication with the necessary properties + * + * @param apiKey: The api key to be used for every request + */ + public constructor({{#useInversify}}@inject(AuthApiKey) @named("{{name}}") {{/useInversify}}private apiKey: string) {} + {{/isApiKey}} + {{#isBasicBasic}} /** * Configures the http authentication with the required details. * + * @param username username for http basic authentication + * @param password password for http basic authentication + */ + public constructor( + {{#useInversify}}@inject(AuthUsername) @named("{{name}}") {{/useInversify}}private username: string, + {{#useInversify}}@inject(AuthPassword) @named("{{name}}") {{/useInversify}}private password: string + ) {} + {{/isBasicBasic}} + {{#isBasicBearer}} + /** + * Configures the http authentication with the required details. * - * @param authName name of the authentication scheme as defined in openapi specification * @param tokenProvider service that can provide the up-to-date token when needed */ - public constructor(authName: string, private tokenProvider: TokenProvider) { - super(authName); + public constructor({{#useInversify}}@inject(AbstractTokenProvider) @named("{{name}}") {{/useInversify}}private tokenProvider: TokenProvider) {} + {{/isBasicBearer}} + {{#isOAuth}} + // TODO: How to handle oauth2 authentication! + public constructor() {} + {{/isOAuth}} + + public getName(): string { + return "{{name}}"; } - public async applySecurityAuthentication(context: RequestContext) { + public {{#isBasicBearer}}async {{/isBasicBearer}}applySecurityAuthentication(context: RequestContext) { + {{#isApiKey}} + context.{{#isKeyInHeader}}setHeaderParam{{/isKeyInHeader}}{{#isKeyInQuery}}addCookie{{/isKeyInQuery}}{{#isKeyInCookie}}setQueryParam{{/isKeyInCookie}}("{{keyParamName}}", this.apiKey); + {{/isApiKey}} + {{#isBasicBasic}} + let comb = this.username + ":" + this.password; + context.setHeaderParam("Authorization", "Basic " + btoa(comb)); + {{/isBasicBasic}} + {{#isBasicBearer}} context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + {{/isBasicBearer}} + {{#isOAuth}} + // TODO + {{/isOAuth}} } } -// TODO: How to handle oauth2 authentication! -export class OAuth2Authentication extends SecurityAuthentication { - public constructor(authName: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - // TODO - } -} +{{/authMethods}} export type AuthMethods = { - {{#authMethods}} - "{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isBasicBasic}}HttpBasicAuthentication{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerAuthentication{{/isBasicBearer}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}}, - {{/authMethods}} + {{#authMethods}} + "{{name}}"?: SecurityAuthentication{{#hasMore}},{{/hasMore}} + {{/authMethods}} } +{{#useInversify}} + +export const authMethodServices = { + {{#authMethods}} + "{{name}}": {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication{{#hasMore}},{{/hasMore}} + {{/authMethods}} +} +{{/useInversify}} export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; -export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } +export type AuthMethodsConfiguration = { + {{#authMethods}} + "{{name}}"?: {{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}{{#hasMore}},{{/hasMore}} + {{/authMethods}} +} /** * Creates the authentication methods from a swagger description. @@ -147,22 +138,24 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine return authMethods; } - {{#authMethods}} + {{#authMethods}} if (config["{{name}}"]) { - {{#isApiKey}} - authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, config["{{name}}"]); - {{/isApiKey}} - {{#isBasicBasic}} - authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]); - {{/isBasicBasic}} - {{#isBasicBearer}} - authMethods["{{name}}"] = new HttpBearerAuthentication("{{name}}", config["{{name}}"]["tokenProvider"]); - {{/isBasicBearer}} - {{#isOAuth}} - authMethods["{{name}}"] = new OAuth2Authentication("{{name}}"); - {{/isOAuth}} - } + authMethods["{{name}}"] = new {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication( + {{#isApiKey}} + config["{{name}}"] + {{/isApiKey}} + {{#isBasicBasic}} + config["{{name}}"]["username"], + config["{{name}}"]["password"] + {{/isBasicBasic}} + {{#isBasicBearer}} + config["{{name}}"]["tokenProvider"] + {{/isBasicBearer}} + {{#isOAuth}} + {{/isOAuth}} + ); + } - {{/authMethods}} - return authMethods; + {{/authMethods}} + return authMethods; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 68c503af56c4..539e9b06138d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,35 +1,42 @@ -import {HttpLibrary} from './http/http'; -import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; {{#frameworks}} {{#fetch-api}} -import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; {{/fetch-api}} {{#jquery}} -import {JQueryHttpLibrary} from "./http/jquery"; +import { JQueryHttpLibrary as DefaultHttpLibrary } from "./http/jquery"; {{/jquery}} {{/frameworks}} -import {ServerConfiguration, server1} from './servers'; -import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + /** - * Inetrface with which a configuration object can be configured. - * + * Interface with which a configuration object can be configured. */ export interface ConfigurationParameters { - /** - * Default server to use - */ - baseServer?: ServerConfiguration; - /** - * HTTP library to use e.g. IsomorphicFetch - */ + /** + * Default server to use + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ httpApi?: HttpLibrary; /** * The middlewares which will be applied to requests and responses */ - middleware?: Middleware[]; // middleware to apply before/after fetch requests + middleware?: Middleware[]; /** - * configures all middlewares using the promise api instead of observables (which Middleware uses) + * Configures all middlewares using the promise api instead of observables (which Middleware uses) */ promiseMiddleware?: PromiseMiddleware[]; /** @@ -38,30 +45,29 @@ export interface ConfigurationParameters { authMethods?: AuthMethodsConfiguration } -export class Configuration { - - baseServer: ServerConfiguration; - httpApi: HttpLibrary; - middleware: Middleware[]; - authMethods: AuthMethods; - - /** - * Creates a new configuration object based on the given configuration. - * If a property is not included in conf, a default is used: - * - baseServer: server1 - * - httpApi: IsomorphicFetchHttpLibrary - * - middleware: [] - * - promiseMiddleware: [] - * - authMethods: {} - * @param conf particial configuration - */ - constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || {{#frameworks}}{{#fetch-api}}new IsomorphicFetchHttpLibrary(){{/fetch-api}}{{#jquery}}new JQueryHttpLibrary{{/jquery}}{{/frameworks}}; // TODO: replace with window.fetch if available? - this.middleware = conf.middleware || []; - this.authMethods = configureAuthMethods(conf.authMethods); - if (conf.promiseMiddleware) { - conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); - } +/** + * Configuration factory function + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); } + return configuration; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index ec5f6f379f37..dffa0dc544e6 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -7,7 +7,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; +import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; {{#frameworks}} {{#fetch-api}} @@ -243,4 +243,16 @@ export class ResponseContext { export interface HttpLibrary { send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache index 41b5d204ec0e..aafda6432172 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache @@ -1,4 +1,8 @@ -import {RequestContext, HttpMethod} from './http/http'; +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} /** * @@ -6,7 +10,7 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { +export class ServerConfiguration implements BaseServerConfiguration { public constructor(private url: string, private variableConfiguration: T) {} /** @@ -47,3 +51,5 @@ export class ServerConfiguration { {{#servers}} export const server{{-index}} = new ServerConfiguration<{ {{#variables}} "{{name}}": {{#enumValues}}"{{.}}"{{^-last}} | {{/-last}}{{/enumValues}}{{^enumValues}}string{{/enumValues}}{{^-last}},{{/-last}} {{/variables}} }>("{{url}}", { {{#variables}} "{{name}}": "{{defaultValue}}" {{^-last}},{{/-last}}{{/variables}} }) {{/servers}} + +export const servers = [{{#servers}}server{{-index}}{{^-last}}, {{/-last}}{{/servers}}]; diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache index d5829b82d26f..2302e5a1b457 100644 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -1,11 +1,11 @@ -import 'es6-promise/auto'; +import "es6-promise/auto"; -export * from './http/http'; -export * from './auth/auth'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './apis/exception'; -export * from './servers'; +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration, Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; {{#useRxJS}} export { Middleware } from './middleware'; @@ -23,4 +23,19 @@ export { {{#apiInfo}}{{#apis}}{{#operations}}Observable{{classname}} as {{classn {{^useRxJS}} export { {{#apiInfo}}{{#apis}}{{#operations}}Promise{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/PromiseAPI'; {{/useRxJS}} -{{/useObjectParameters}} \ No newline at end of file +{{/useObjectParameters}} + +{{#useInversify}} +export * from "./services/index"; +{{#useObjectParameters}} +export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractObject{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/ObjectParamAPI'; +{{/useObjectParameters}} +{{^useObjectParameters}} +{{#useRxJS}} +export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractObservable{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/ObservableAPI'; +{{/useRxJS}} +{{^useRxJS}} +export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractPromise{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/PromiseAPI'; +{{/useRxJS}} +{{/useObjectParameters}} +{{/useInversify}} diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 14d9b9e8dfd1..0adbf68d9a14 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -42,8 +42,11 @@ {{/node}} {{/platforms}} {{#useRxJS}} - "rxjs": "^6.4.0", + "rxjs": "^6.4.0", {{/useRxJS}} + {{#useInversify}} + "inversify": "^5.0.1", + {{/useInversify}} "es6-promise": "^4.2.4", "url-parse": "^1.4.3" }, diff --git a/modules/openapi-generator/src/main/resources/typescript/services/ObjectParamAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/services/ObjectParamAPI.mustache new file mode 100644 index 000000000000..1c34257dcfa7 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/ObjectParamAPI.mustache @@ -0,0 +1,35 @@ +import type { HttpFile } from '../http/http'; +import type { Configuration } from '../configuration' +import type * as req from "../types/ObjectParamAPI"; +{{#useRxJS}} +import type { Observable } from 'rxjs'; +{{/useRxJS}} + +{{#models}} +{{#model}} +import type { {{{ classname }}} } from '../models/{{{ classFilename }}}'; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} +{{#operations}} + + +export abstract class AbstractObject{{classname}} { + {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + * @param param the request object + */ + public abstract {{nickname}}(param: req.{{classname}}{{operationIdCamelCase}}Request, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>; + + {{/operation}} +} +{{/operations}} +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/services/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/services/ObservableAPI.mustache new file mode 100644 index 000000000000..209436b07b41 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/ObservableAPI.mustache @@ -0,0 +1,23 @@ +import type { HttpFile } from "../http/http"; +import type { Observable } from {{#useRxJS}}"rxjs"{{/useRxJS}}{{^useRxJS}}"../rxjsStub"{{/useRxJS}}; +import type { Configuration } from "../configuration"; + +{{#models}} +{{#model}} +import { {{{ classname }}} } from "../models/{{{ classFilename }}}"; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} +{{#operations}} + + +export abstract class AbstractObservable{{classname}} { + {{#operation}} + public abstract {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>; + + {{/operation}} +} +{{/operations}} +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/services/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/services/PromiseAPI.mustache new file mode 100644 index 000000000000..d3403ff707a4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/PromiseAPI.mustache @@ -0,0 +1,22 @@ +import type { HttpFile } from "../http/http"; +import type { Configuration } from "../configuration"; + +{{#models}} +{{#model}} +import { {{{ classname }}} } from "../models/{{{ classFilename }}}"; +{{/model}} +{{/models}} +{{#apiInfo}} +{{#apis}} +{{#operations}} + + +export abstract class AbstractPromise{{classname}} { + {{#operation}} + public abstract {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>; + + {{/operation}} +} +{{/operations}} +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/services/api.mustache b/modules/openapi-generator/src/main/resources/typescript/services/api.mustache new file mode 100644 index 000000000000..8992017a7065 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/api.mustache @@ -0,0 +1,23 @@ +import type { Configuration } from "../configuration"; +import type { HttpFile, RequestContext, ResponseContext } from "../http/http"; + +{{#imports}} +import { {{classname}} } from "..{{filename}}"; +{{/imports}} +{{#operations}} + +export abstract class Abstract{{classname}}RequestFactory { + {{#operation}} + public abstract {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise; + + {{/operation}} +} + + +export abstract class Abstract{{classname}}ResponseProcessor { + {{#operation}} + public abstract {{nickname}}(response: ResponseContext): Promise<{{#returnType}}{{{returnType}}}{{/returnType}} {{^returnType}}void{{/returnType}}>; + + {{/operation}} +} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript/services/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/services/configuration.mustache new file mode 100644 index 000000000000..06e8dc992fcc --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/configuration.mustache @@ -0,0 +1,21 @@ +import type { AbstractServerConfiguration } from "./http"; +import type { HttpLibrary, RequestContext } from "../http/http"; +import type { Middleware } from "../middleware"; +import type { AuthMethods, TokenProvider } from "../auth/auth"; +import type { Configuration } from "../configuration"; + +export abstract class AbstractConfiguration implements Configuration { + abstract get baseServer(): AbstractServerConfiguration; + abstract get httpApi(): HttpLibrary; + abstract get middleware(): Middleware[]; + abstract get authMethods(): AuthMethods; +} + +export abstract class AbstractAuthMethod { + public abstract getName(): string; + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; +}; + +export abstract class AbstractTokenProvider implements TokenProvider { + public abstract getToken(): string | Promise; +} diff --git a/modules/openapi-generator/src/main/resources/typescript/services/http.mustache b/modules/openapi-generator/src/main/resources/typescript/services/http.mustache new file mode 100644 index 000000000000..89bda7bf3e3d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/http.mustache @@ -0,0 +1,20 @@ +{{#useRxJS}} +import type { Observable } from "rxjs"; +{{/useRxJS}} +import type { {{^useRxJS}}Promise{{/useRxJS}}HttpLibrary, HttpMethod, RequestContext, ResponseContext } from "../http/http"; +import type { {{^useRxJS}}Promise{{/useRxJS}}Middleware } from "../middleware"; +import type { BaseServerConfiguration } from "../servers"; + +export abstract class AbstractHttpLibrary implements {{^useRxJS}}Promise{{/useRxJS}}HttpLibrary { + public abstract send(request: RequestContext): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}; +}; + +export abstract class AbstractMiddleware implements {{^useRxJS}}Promise{{/useRxJS}}Middleware { + public abstract pre(context: RequestContext): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}; + public abstract post(context: ResponseContext): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}; +} + +export abstract class AbstractServerConfiguration implements BaseServerConfiguration { + public abstract makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +}; + diff --git a/modules/openapi-generator/src/main/resources/typescript/services/index.mustache b/modules/openapi-generator/src/main/resources/typescript/services/index.mustache new file mode 100644 index 000000000000..0b662f5d4d33 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/services/index.mustache @@ -0,0 +1,165 @@ +import { inject, injectable, multiInject, optional, interfaces } from "inversify"; + +import { Configuration } from "../configuration"; +import { ServerConfiguration, servers } from "../servers"; +import { HttpLibrary{{^useRxJS}}, wrapHttpLibrary{{/useRxJS}} } from "../http/http"; +import { Middleware{{^useRxJS}}, PromiseMiddlewareWrapper{{/useRxJS}} } from "../middleware"; +import { authMethodServices, AuthMethods } from "../auth/auth"; + +{{#frameworks}} +{{#fetch-api}} +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "../http/isomorphic-fetch"; +{{/fetch-api}} +{{#jquery}} +import { JQueryHttpLibrary as DefaultHttpLibrary } from "../http/jquery"; +{{/jquery}} +{{/frameworks}} + +import { AbstractHttpLibrary, AbstractMiddleware, AbstractServerConfiguration } from "./http"; +import { AbstractConfiguration, AbstractAuthMethod, AbstractTokenProvider } from "./configuration"; + +export { AbstractHttpLibrary, AbstractMiddleware, AbstractServerConfiguration, AbstractConfiguration, AbstractAuthMethod, AbstractTokenProvider }; + +{{#useObjectParameters}} +import * as apis from "../types/ObjectParamAPI"; +import * as apiServices from "./ObjectParamAPI"; +{{/useObjectParameters}} +{{^useObjectParameters}} +{{#useRxJS}} +import * as apis from "../types/ObservableAPI"; +import * as apiServices from "./ObservableAPI"; +{{/useRxJS}} +{{^useRxJS}} +import * as apis from "../types/PromiseAPI"; +import * as apiServices from "./PromiseAPI"; +{{/useRxJS}} +{{/useObjectParameters}} + +@injectable() +class InjectableConfiguration implements AbstractConfiguration { + public httpApi: HttpLibrary = new DefaultHttpLibrary(); + public middleware: Middleware[] = []; + public authMethods: AuthMethods = {}; + + constructor( + @inject(AbstractServerConfiguration) @optional() public baseServer: AbstractServerConfiguration = servers[0], + @inject(AbstractHttpLibrary) @optional() httpApi: AbstractHttpLibrary, + @multiInject(AbstractMiddleware) @optional() middleware: AbstractMiddleware[] = [], + @multiInject(AbstractAuthMethod) @optional() securityConfiguration: AbstractAuthMethod[] = [] + ) { + {{#useRxJS}} + this.httpApi = httpApi || new DefaultHttpLibrary(); + this.middleware = middleware; + {{/useRxJS}} + {{^useRxJS}} + this.httpApi = httpApi === undefined ? new DefaultHttpLibrary() : wrapHttpLibrary(httpApi); + for (const _middleware of middleware) { + this.middleware.push(new PromiseMiddlewareWrapper(_middleware)); + } + {{/useRxJS}} + for (const authMethod of securityConfiguration) { + const authName = authMethod.getName(); + // @ts-ignore + if (authMethodServices[authName] !== undefined) { + // @ts-ignore + this.authMethods[authName] = authMethod; + } + } + } +} + +/** + * Helper class to simplify binding the services + */ +export class ApiServiceBinder { + constructor(private container: interfaces.Container) { + this.container.bind(AbstractConfiguration).to(InjectableConfiguration); + } + + /** + * Allows you to bind a server configuration without having to import the service identifier. + */ + public get bindServerConfiguration() { + return this.container.bind(AbstractServerConfiguration); + } + + /** + * Use one of the predefined server configurations. + * + * To customize the server variables you can call `setVariables` on the + * return value; + */ + public bindServerConfigurationToPredefined(idx: number) { + this.bindServerConfiguration.toConstantValue(servers[idx]); + return servers[idx]; + } + + /** + * Explicitly define the service base url + */ + public bindServerConfigurationToURL(url: string) { + return this.bindServerConfiguration.toConstantValue( + new ServerConfiguration<{}>(url, {}) + ); + } + + /** + * Allows you to bind a http library without having to import the service identifier. + */ + public get bindHttpLibrary() { + return this.container.bind(AbstractHttpLibrary); + } + + /** + * Allows you to bind a middleware without having to import the service identifier. + * + * You can bind multiple middlewares by calling this multiple method times. + */ + public get bindMiddleware() { + return this.container.bind(AbstractMiddleware); + } + + /** + * Allows you to bind an auth method without having to import the service identifier. + * + * Note: The name of the bound auth method needs to be known in the specs, + * because the name is used to decide for which endpoints to apply the authentication. + */ + public get bindAuthMethod() { + return this.container.bind(AbstractAuthMethod); + } + + /** + * Use one of the predefined auth methods. + * + * Make sure that you have injected all dependencies for it. + */ + public bindAuthMethodToPredefined(name: keyof AuthMethods) { + return this.bindAuthMethod.to(authMethodServices[name]); + } + + /** + * Bind all the apis to their respective service identifiers + * + * If you want to only bind some of the apis, you need to do that manually. + */ + public bindAllApiServices() { + {{#apiInfo}} + {{#apis}} + {{#operations}} + {{#useObjectParameters}} + this.container.bind(apiServices.AbstractObject{{classname}}).to(apis.Object{{classname}}).inSingletonScope(); + {{/useObjectParameters}} + {{^useObjectParameters}} + {{#useRxJS}} + this.container.bind(apiServices.AbstractObservable{{classname}}).to(apis.Observable{{classname}}).inSingletonScope(); + {{/useRxJS}} + {{^useRxJS}} + this.container.bind(apiServices.AbstractPromise{{classname}}).to(apis.Promise{{classname}}).inSingletonScope(); + {{/useRxJS}} + {{/useObjectParameters}} + {{/operations}} + {{/apis}} + {{/apiInfo}} + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache index 5831f2409da0..674e7a64d3ae 100644 --- a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache @@ -4,6 +4,7 @@ /* Basic Options */ "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", "module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}", + "moduleResolution": "node", "declaration": true, /* Additional Checks */ @@ -18,12 +19,15 @@ "noLib": false, {{#platforms}} {{#node}} - "lib": [ "es6" ] + "lib": [ "es6" ], {{/node}} {{#browser}} - "lib": [ "es6", "dom" ] + "lib": [ "es6", "dom" ], {{/browser}} {{/platforms}} + {{#useInversify}} + "experimentalDecorators": true, + {{/useInversify}} }, "exclude": [ "dist", diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache index 16d926d1c55f..b9469283be38 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache @@ -1,6 +1,9 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' +{{#useRxJS}} +import { Observable } from 'rxjs'; +{{/useRxJS}} {{#models}} {{#model}} diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache index 6590d71aca58..79e1630a2654 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache @@ -3,6 +3,10 @@ import * as models from '../models/all'; import { Configuration} from '../configuration' import { Observable, of, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; +{{#useInversify}} +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; +{{/useInversify}} {{#models}} {{#model}} @@ -14,16 +18,38 @@ import { {{{ classname }}} } from '../models/{{{ classFilename }}}'; {{#operations}} import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; +{{#useInversify}} +import { Abstract{{classname}}RequestFactory, Abstract{{classname}}ResponseProcessor } from "../apis/{{classname}}.service"; + +@injectable() +{{/useInversify}} export class Observable{{classname}} { - private requestFactory: {{classname}}RequestFactory; - private responseProcessor: {{classname}}ResponseProcessor; + {{#useInversify}} + private requestFactory: Abstract{{classname}}RequestFactory; + private responseProcessor: Abstract{{classname}}ResponseProcessor; + {{/useInversify}} + {{^useInversify}} + private requestFactory: {{classname}}RequestFactory; + private responseProcessor: {{classname}}ResponseProcessor; + {{/useInversify}} private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: {{classname}}RequestFactory, responseProcessor?: {{classname}}ResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new {{classname}}RequestFactory(configuration); - this.responseProcessor = responseProcessor || new {{classname}}ResponseProcessor(); - } + + public constructor( + {{#useInversify}} + @inject(AbstractConfiguration) configuration: Configuration, + @inject(Abstract{{classname}}RequestFactory) @optional() requestFactory?: Abstract{{classname}}RequestFactory, + @inject(Abstract{{classname}}ResponseProcessor) @optional() responseProcessor?: Abstract{{classname}}ResponseProcessor + {{/useInversify}} + {{^useInversify}} + configuration: Configuration, + requestFactory?: {{classname}}RequestFactory, + responseProcessor?: {{classname}}ResponseProcessor + {{/useInversify}} + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new {{classname}}RequestFactory(configuration); + this.responseProcessor = responseProcessor || new {{classname}}ResponseProcessor(); + } {{#operation}} /** diff --git a/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache index dae804a53481..1bb0bdefe84c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache @@ -1,6 +1,10 @@ import { ResponseContext, RequestContext, HttpFile } from '../http/http'; import * as models from '../models/all'; import { Configuration} from '../configuration' +{{#useInversify}} +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; +{{/useInversify}} {{#models}} {{#model}} @@ -14,12 +18,28 @@ import { Observable{{classname}} } from './ObservableAPI'; {{#operations}} import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}"; +{{#useInversify}} +import { Abstract{{classname}}RequestFactory, Abstract{{classname}}ResponseProcessor } from "../apis/{{classname}}.service"; + +@injectable() +{{/useInversify}} export class Promise{{classname}} { private api: Observable{{classname}} - - public constructor(configuration: Configuration, requestFactory?: {{classname}}RequestFactory, responseProcessor?: {{classname}}ResponseProcessor) { + + public constructor( + {{#useInversify}} + @inject(AbstractConfiguration) configuration: Configuration, + @inject(Abstract{{classname}}RequestFactory) @optional() requestFactory?: Abstract{{classname}}RequestFactory, + @inject(Abstract{{classname}}ResponseProcessor) @optional() responseProcessor?: Abstract{{classname}}ResponseProcessor + {{/useInversify}} + {{^useInversify}} + configuration: Configuration, + requestFactory?: {{classname}}RequestFactory, + responseProcessor?: {{classname}}ResponseProcessor + {{/useInversify}} + ) { this.api = new Observable{{classname}}(configuration, requestFactory, responseProcessor); - } + } {{#operation}} /** diff --git a/pom.xml b/pom.xml index 9244a541cf86..6b30ab508c5d 100644 --- a/pom.xml +++ b/pom.xml @@ -1210,6 +1210,8 @@ samples/openapi3/client/petstore/typescript/tests/jquery samples/openapi3/client/petstore/typescript/builds/object_params samples/openapi3/client/petstore/typescript/tests/object_params + samples/openapi3/client/petstore/typescript/builds/inversify + samples/openapi3/client/petstore/typescript/tests/inversify samples/client/petstore/typescript-fetch/builds/default samples/client/petstore/typescript-fetch/builds/es6-target samples/client/petstore/typescript-fetch/builds/with-npm-version diff --git a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts index 8a3686484567..9d59a0a25580 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/auth/auth.ts @@ -1,86 +1,23 @@ -import {RequestContext} from '../http/http'; // typings for btoa are incorrect //@ts-ignore import * as btoa from "btoa"; -/** - * Base class for all authentication schemes. - * - */ -export abstract class SecurityAuthentication { - - public constructor(private name: string) { - - } - - /* - * - * @return returns the name of the security authentication as specified in OAI - */ - public getName(): string { - return this.name; - } - - /** - * Applies the authentication scheme to the request context - * - * @params context the request context which should use this authentication scheme - */ - public abstract applySecurityAuthentication(context: RequestContext): void | Promise; - -} +import { RequestContext } from "../http/http"; /** - * Applies an api key to the request context. - * + * Interface authentication schemes. */ -export class APIKeyAuthentication extends SecurityAuthentication { - - /** - * Configures this api key authentication with the necessary properties - * - * @param authName: name of this authentication scheme as specified in the swagger.json - * @param paramName: Parameter name used for the api key - * @param keyLocation: Parameter location, either query, header or cookie. - * @param apiKey: The api key to be used for every request - */ - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - if (this.keyLocation === "header") { - context.setHeaderParam(this.paramName, this.apiKey); - } else if (this.keyLocation === "cookie") { - context.addCookie(this.paramName, this.apiKey); - } else if (this.keyLocation === "query") { - context.setQueryParam(this.paramName, this.apiKey); - } - } -} - +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; -/** - * Applies basic http authentication to a request. - * - */ -export class HttpBasicAuthentication extends SecurityAuthentication { - - /** - * Configures the http authentication with the required details. - * - * - * @param authName name of the authentication scheme as defined in swagger json - * @param username username for http basic authentication - * @param password password for http basic authentication - */ - public constructor(authName: string, private username: string, private password: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - let comb = this.username + ":" + this.password; - context.setHeaderParam("Authorization", "Basic " + btoa(comb)); - } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; } export interface TokenProvider { @@ -88,40 +25,45 @@ export interface TokenProvider { } /** - * Applies http bearer authentication to a request. - * + * Applies apiKey authentication to the request context. */ -export class HttpBearerAuthentication extends SecurityAuthentication { +export class ApiKeyAuthentication implements SecurityAuthentication { /** - * Configures the http authentication with the required details. + * Configures this api key authentication with the necessary properties * - * - * @param authName name of the authentication scheme as defined in openapi specification - * @param tokenProvider service that can provide the up-to-date token when needed + * @param apiKey: The api key to be used for every request */ - public constructor(authName: string, private tokenProvider: TokenProvider) { - super(authName); + public constructor(private apiKey: string) {} + + public getName(): string { + return "api_key"; } - public async applySecurityAuthentication(context: RequestContext) { - context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + public applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("api_key", this.apiKey); } } -// TODO: How to handle oauth2 authentication! -export class OAuth2Authentication extends SecurityAuthentication { - public constructor(authName: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - // TODO - } +/** + * Applies oauth2 authentication to the request context. + */ +export class PetstoreAuthAuthentication implements SecurityAuthentication { + // TODO: How to handle oauth2 authentication! + public constructor() {} + + public getName(): string { + return "petstore_auth"; + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } } + export type AuthMethods = { - "api_key"?: APIKeyAuthentication, - "petstore_auth"?: OAuth2Authentication, + "api_key"?: SecurityAuthentication, + "petstore_auth"?: SecurityAuthentication } export type ApiKeyConfiguration = string; @@ -129,7 +71,10 @@ export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; -export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } +export type AuthMethodsConfiguration = { + "api_key"?: ApiKeyConfiguration, + "petstore_auth"?: OAuth2Configuration +} /** * Creates the authentication methods from a swagger description. @@ -143,12 +88,15 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine } if (config["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); - } + authMethods["api_key"] = new ApiKeyAuthentication( + config["api_key"] + ); + } if (config["petstore_auth"]) { - authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); - } + authMethods["petstore_auth"] = new PetstoreAuthAuthentication( + ); + } - return authMethods; + return authMethods; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/default/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/default/configuration.ts index 73f53c7dd211..b78d85972a4a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/configuration.ts @@ -1,28 +1,35 @@ -import {HttpLibrary} from './http/http'; -import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; -import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; -import {ServerConfiguration, server1} from './servers'; -import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + /** - * Inetrface with which a configuration object can be configured. - * + * Interface with which a configuration object can be configured. */ export interface ConfigurationParameters { - /** - * Default server to use - */ - baseServer?: ServerConfiguration; - /** - * HTTP library to use e.g. IsomorphicFetch - */ + /** + * Default server to use + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ httpApi?: HttpLibrary; /** * The middlewares which will be applied to requests and responses */ - middleware?: Middleware[]; // middleware to apply before/after fetch requests + middleware?: Middleware[]; /** - * configures all middlewares using the promise api instead of observables (which Middleware uses) + * Configures all middlewares using the promise api instead of observables (which Middleware uses) */ promiseMiddleware?: PromiseMiddleware[]; /** @@ -31,30 +38,29 @@ export interface ConfigurationParameters { authMethods?: AuthMethodsConfiguration } -export class Configuration { - - baseServer: ServerConfiguration; - httpApi: HttpLibrary; - middleware: Middleware[]; - authMethods: AuthMethods; - - /** - * Creates a new configuration object based on the given configuration. - * If a property is not included in conf, a default is used: - * - baseServer: server1 - * - httpApi: IsomorphicFetchHttpLibrary - * - middleware: [] - * - promiseMiddleware: [] - * - authMethods: {} - * @param conf particial configuration - */ - constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? - this.middleware = conf.middleware || []; - this.authMethods = configureAuthMethods(conf.authMethods); - if (conf.promiseMiddleware) { - conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); - } +/** + * Configuration factory function + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); } + return configuration; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/default/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/default/http/http.ts index 6de17431aa26..ac32e72aa981 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/http/http.ts @@ -3,7 +3,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from '../rxjsStub'; +import { Observable, from } from '../rxjsStub'; export * from './isomorphic-fetch'; @@ -191,4 +191,16 @@ export class ResponseContext { export interface HttpLibrary { send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/default/index.ts b/samples/openapi3/client/petstore/typescript/builds/default/index.ts index 994fe9dec6d1..cbc24ba3554d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/index.ts @@ -1,11 +1,12 @@ -import 'es6-promise/auto'; +import "es6-promise/auto"; -export * from './http/http'; -export * from './auth/auth'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './apis/exception'; -export * from './servers'; +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration, Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; + diff --git a/samples/openapi3/client/petstore/typescript/builds/default/servers.ts b/samples/openapi3/client/petstore/typescript/builds/default/servers.ts index 2124324986d7..aa5332db7ae9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/servers.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/servers.ts @@ -1,4 +1,8 @@ -import {RequestContext, HttpMethod} from './http/http'; +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} /** * @@ -6,7 +10,7 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { +export class ServerConfiguration implements BaseServerConfiguration { public constructor(private url: string, private variableConfiguration: T) {} /** @@ -45,3 +49,5 @@ export class ServerConfiguration { } export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) + +export const servers = [server1]; diff --git a/samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json index 0f376008e1a6..a542d795677c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/default/tsconfig.json @@ -4,6 +4,7 @@ /* Basic Options */ "target": "es5", "module": "commonjs", + "moduleResolution": "node", "declaration": true, /* Additional Checks */ @@ -16,7 +17,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6" ] + "lib": [ "es6" ], }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts index 35d8b2c428f7..30be6fff1f82 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/ObservableAPI.ts @@ -15,15 +15,19 @@ import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class ObservablePetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } /** * Add a new pet to the store @@ -225,15 +229,19 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class ObservableStoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -337,15 +345,19 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class ObservableUserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts index 159708737069..44829ca43fa8 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/types/PromiseAPI.ts @@ -16,10 +16,14 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class PromisePetApi { private api: ObservablePetApi - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); - } + } /** * Add a new pet to the store @@ -112,10 +116,14 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class PromiseStoreApi { private api: ObservableStoreApi - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); - } + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -166,10 +174,14 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class PromiseUserApi { private api: ObservableUserApi - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); - } + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.gitignore b/samples/openapi3/client/petstore/typescript/builds/inversify/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator-ignore b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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 +# This 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 diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES new file mode 100644 index 000000000000..d580da4ce9e9 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/FILES @@ -0,0 +1,41 @@ +.gitignore +README.md +apis/PetApi.service.ts +apis/PetApi.ts +apis/StoreApi.service.ts +apis/StoreApi.ts +apis/UserApi.service.ts +apis/UserApi.ts +apis/baseapi.ts +apis/exception.ts +auth/auth.ts +configuration.ts +git_push.sh +http/http.ts +http/isomorphic-fetch.ts +index.ts +middleware.ts +models/ApiResponse.ts +models/Category.ts +models/InlineObject.ts +models/InlineObject1.ts +models/ObjectSerializer.ts +models/Order.ts +models/Pet.ts +models/Tag.ts +models/User.ts +models/all.ts +package.json +rxjsStub.ts +servers.ts +services/ObjectParamAPI.ts +services/ObservableAPI.ts +services/PromiseAPI.ts +services/configuration.ts +services/http.ts +services/index.ts +tsconfig.json +types/ObjectParamAPI.ts +types/ObservableAPI.ts +types/PromiseAPI.ts +util.ts diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/VERSION b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/VERSION new file mode 100644 index 000000000000..d99e7162d01f --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/README.md b/samples/openapi3/client/petstore/typescript/builds/inversify/README.md new file mode 100644 index 000000000000..80b1ac5cc98b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/README.md @@ -0,0 +1,30 @@ +## ts-petstore-client@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes fetch-api. + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install ts-petstore-client@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.service.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.service.ts new file mode 100644 index 000000000000..e96ab5e14824 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.service.ts @@ -0,0 +1,44 @@ +import type { Configuration } from "../configuration"; +import type { HttpFile, RequestContext, ResponseContext } from "../http/http"; + +import { ApiResponse } from "../models/ApiResponse"; +import { Pet } from "../models/Pet"; + +export abstract class AbstractPetApiRequestFactory { + public abstract addPet(pet: Pet, options?: Configuration): Promise; + + public abstract deletePet(petId: number, apiKey?: string, options?: Configuration): Promise; + + public abstract findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise; + + public abstract findPetsByTags(tags: Array, options?: Configuration): Promise; + + public abstract getPetById(petId: number, options?: Configuration): Promise; + + public abstract updatePet(pet: Pet, options?: Configuration): Promise; + + public abstract updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise; + + public abstract uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise; + +} + + +export abstract class AbstractPetApiResponseProcessor { + public abstract addPet(response: ResponseContext): Promise; + + public abstract deletePet(response: ResponseContext): Promise< void>; + + public abstract findPetsByStatus(response: ResponseContext): Promise >; + + public abstract findPetsByTags(response: ResponseContext): Promise >; + + public abstract getPetById(response: ResponseContext): Promise; + + public abstract updatePet(response: ResponseContext): Promise; + + public abstract updatePetWithForm(response: ResponseContext): Promise< void>; + + public abstract uploadFile(response: ResponseContext): Promise; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts new file mode 100644 index 000000000000..c97b44cf0893 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/PetApi.ts @@ -0,0 +1,653 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; + +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; + +/** + * no description + */ +@injectable() +export class PetApiRequestFactory extends BaseAPIRequestFactory { + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public async addPet(pet: Pet, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(pet, "Pet", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", "")); + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + + + // Path Params + const localVarPath = '/pet/findByStatus'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (status !== undefined) { + requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public async findPetsByTags(tags: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + + + // Path Params + const localVarPath = '/pet/findByTags'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (tags !== undefined) { + requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public async getPetById(petId: number, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public async updatePet(pet: Pet, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(pet, "Pet", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * 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 async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (name !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('name', name as any); + } + if (status !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('status', status as any); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + + + // Path Params + const localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + let localVarFormParams = new FormData(); + + if (additionalMetadata !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + if (file !== undefined) { + // TODO: replace .append with .set + localVarFormParams.append('file', file.data, file.name); + } + requestContext.setBody(localVarFormParams); + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["petstore_auth"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + + + +@injectable() +export class PetApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to addPet + * @throws ApiException if the response code was not in [200, 299] + */ + public async addPet(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deletePet + * @throws ApiException if the response code was not in [200, 299] + */ + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid pet value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByStatus + * @throws ApiException if the response code was not in [200, 299] + */ + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid status value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to findPetsByTags + * @throws ApiException if the response code was not in [200, 299] + */ + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid tag value"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getPetById + * @throws ApiException if the response code was not in [200, 299] + */ + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePet + * @throws ApiException if the response code was not in [200, 299] + */ + public async updatePet(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Pet not found"); + } + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Validation exception"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updatePetWithForm + * @throws ApiException if the response code was not in [200, 299] + */ + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("405", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid input"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to uploadFile + * @throws ApiException if the response code was not in [200, 299] + */ + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.service.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.service.ts new file mode 100644 index 000000000000..b2e61032a7f6 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.service.ts @@ -0,0 +1,27 @@ +import type { Configuration } from "../configuration"; +import type { HttpFile, RequestContext, ResponseContext } from "../http/http"; + +import { Order } from "../models/Order"; + +export abstract class AbstractStoreApiRequestFactory { + public abstract deleteOrder(orderId: string, options?: Configuration): Promise; + + public abstract getInventory(options?: Configuration): Promise; + + public abstract getOrderById(orderId: number, options?: Configuration): Promise; + + public abstract placeOrder(order: Order, options?: Configuration): Promise; + +} + + +export abstract class AbstractStoreApiResponseProcessor { + public abstract deleteOrder(response: ResponseContext): Promise< void>; + + public abstract getInventory(response: ResponseContext): Promise<{ [key: string]: number; } >; + + public abstract getOrderById(response: ResponseContext): Promise; + + public abstract placeOrder(response: ResponseContext): Promise; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts new file mode 100644 index 000000000000..ceef209c37db --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/StoreApi.ts @@ -0,0 +1,298 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; + +import { Order } from '../models/Order'; + +/** + * no description + */ +@injectable() +export class StoreApiRequestFactory extends BaseAPIRequestFactory { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public async deleteOrder(orderId: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public async getInventory(options?: Configuration): Promise { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/store/inventory'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public async getOrderById(orderId: number, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public async placeOrder(order: Order, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + } + + + // Path Params + const localVarPath = '/store/order'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(order, "Order", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + + return requestContext; + } + +} + + + +@injectable() +export class StoreApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteOrder + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getInventory + * @throws ApiException if the response code was not in [200, 299] + */ + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getOrderById + * @throws ApiException if the response code was not in [200, 299] + */ + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Order not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to placeOrder + * @throws ApiException if the response code was not in [200, 299] + */ + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid Order"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.service.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.service.ts new file mode 100644 index 000000000000..0ea540fef877 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.service.ts @@ -0,0 +1,43 @@ +import type { Configuration } from "../configuration"; +import type { HttpFile, RequestContext, ResponseContext } from "../http/http"; + +import { User } from "../models/User"; + +export abstract class AbstractUserApiRequestFactory { + public abstract createUser(user: User, options?: Configuration): Promise; + + public abstract createUsersWithArrayInput(user: Array, options?: Configuration): Promise; + + public abstract createUsersWithListInput(user: Array, options?: Configuration): Promise; + + public abstract deleteUser(username: string, options?: Configuration): Promise; + + public abstract getUserByName(username: string, options?: Configuration): Promise; + + public abstract loginUser(username: string, password: string, options?: Configuration): Promise; + + public abstract logoutUser(options?: Configuration): Promise; + + public abstract updateUser(username: string, user: User, options?: Configuration): Promise; + +} + + +export abstract class AbstractUserApiResponseProcessor { + public abstract createUser(response: ResponseContext): Promise< void>; + + public abstract createUsersWithArrayInput(response: ResponseContext): Promise< void>; + + public abstract createUsersWithListInput(response: ResponseContext): Promise< void>; + + public abstract deleteUser(response: ResponseContext): Promise< void>; + + public abstract getUserByName(response: ResponseContext): Promise; + + public abstract loginUser(response: ResponseContext): Promise; + + public abstract logoutUser(response: ResponseContext): Promise< void>; + + public abstract updateUser(response: ResponseContext): Promise< void>; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts new file mode 100644 index 000000000000..353bae433c58 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/UserApi.ts @@ -0,0 +1,590 @@ +// TODO: better import syntax? +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import {Configuration} from '../configuration'; +import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import * as FormData from "form-data"; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {isCodeInRange} from '../util'; +import { injectable } from "inversify"; + +import { User } from '../models/User'; + +/** + * no description + */ +@injectable() +export class UserApiRequestFactory extends BaseAPIRequestFactory { + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public async createUser(user: User, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); + } + + + // Path Params + const localVarPath = '/user'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "User", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public async createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithArray'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public async createUsersWithListInput(user: Array, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithList'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "Array", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public async deleteUser(username: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public async getUserByName(username: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public async loginUser(username: string, password: string, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + + + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + + + // Path Params + const localVarPath = '/user/login'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (username !== undefined) { + requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string", "")); + } + if (password !== undefined) { + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "")); + } + + // Header Params + + // Form Params + + + // Body Params + + // Apply auth methods + + return requestContext; + } + + /** + * Logs out current logged in user session + */ + public async logoutUser(options?: Configuration): Promise { + let config = options || this.configuration; + + // Path Params + const localVarPath = '/user/logout'; + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public async updateUser(username: string, user: User, options?: Configuration): Promise { + let config = options || this.configuration; + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + + // Header Params + + // Form Params + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(user, "User", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = config.authMethods["api_key"] + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + + + +@injectable() +export class UserApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithArrayInput + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUsersWithListInput + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getUserByName + * @throws ApiException if the response code was not in [200, 299] + */ + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to loginUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to logoutUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("0", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "successful operation"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateUser + * @throws ApiException if the response code was not in [200, 299] + */ + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("400", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "Invalid user supplied"); + } + if (isCodeInRange("404", response.httpStatusCode)) { + throw new ApiException(response.httpStatusCode, "User not found"); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + let body = response.body || ""; + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); + } + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts new file mode 100644 index 000000000000..cf8fec079eb3 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/baseapi.ts @@ -0,0 +1,40 @@ +import { Configuration } from '../configuration' +import { injectable, inject } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +@injectable() +export class BaseAPIRequestFactory { + + constructor(@inject(AbstractConfiguration) protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/apis/exception.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/exception.ts new file mode 100644 index 000000000000..b76dca5aa4bc --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/apis/exception.ts @@ -0,0 +1,14 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ +export class ApiException extends Error { + public constructor(public code: number, public body: T) { + super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body)) + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts new file mode 100644 index 000000000000..13e3b17fa825 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/auth/auth.ts @@ -0,0 +1,115 @@ +// typings for btoa are incorrect +//@ts-ignore +import * as btoa from "btoa"; +import { RequestContext } from "../http/http"; +import { injectable, inject, named } from "inversify"; +import { AbstractTokenProvider } from "../services/configuration"; + +/** + * Interface authentication schemes. + */ +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; + + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; +} + +export const AuthApiKey = Symbol("auth.api_key"); +export const AuthUsername = Symbol("auth.username"); +export const AuthPassword = Symbol("auth.password"); + +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies apiKey authentication to the request context. + */ +@injectable() +export class ApiKeyAuthentication implements SecurityAuthentication { + /** + * Configures this api key authentication with the necessary properties + * + * @param apiKey: The api key to be used for every request + */ + public constructor(@inject(AuthApiKey) @named("api_key") private apiKey: string) {} + + public getName(): string { + return "api_key"; + } + + public applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("api_key", this.apiKey); + } +} + +/** + * Applies oauth2 authentication to the request context. + */ +@injectable() +export class PetstoreAuthAuthentication implements SecurityAuthentication { + // TODO: How to handle oauth2 authentication! + public constructor() {} + + public getName(): string { + return "petstore_auth"; + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + + +export type AuthMethods = { + "api_key"?: SecurityAuthentication, + "petstore_auth"?: SecurityAuthentication +} + +export const authMethodServices = { + "api_key": ApiKeyAuthentication, + "petstore_auth": PetstoreAuthAuthentication +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { + "api_key"?: ApiKeyConfiguration, + "petstore_auth"?: OAuth2Configuration +} + +/** + * Creates the authentication methods from a swagger description. + * + */ +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} + + if (!config) { + return authMethods; + } + + if (config["api_key"]) { + authMethods["api_key"] = new ApiKeyAuthentication( + config["api_key"] + ); + } + + if (config["petstore_auth"]) { + authMethods["petstore_auth"] = new PetstoreAuthAuthentication( + ); + } + + return authMethods; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/configuration.ts new file mode 100644 index 000000000000..b78d85972a4a --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/configuration.ts @@ -0,0 +1,66 @@ +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + + +/** + * Interface with which a configuration object can be configured. + */ +export interface ConfigurationParameters { + /** + * Default server to use + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ + httpApi?: HttpLibrary; + /** + * The middlewares which will be applied to requests and responses + */ + middleware?: Middleware[]; + /** + * Configures all middlewares using the promise api instead of observables (which Middleware uses) + */ + promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods + */ + authMethods?: AuthMethodsConfiguration +} + +/** + * Configuration factory function + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); + } + return configuration; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/git_push.sh b/samples/openapi3/client/petstore/typescript/builds/inversify/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/git_push.sh @@ -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 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="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="Minor update" + 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 credential 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' + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/http/http.ts new file mode 100644 index 000000000000..ac32e72aa981 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/http/http.ts @@ -0,0 +1,206 @@ +// TODO: evaluate if we can easily get rid of this library +import * as FormData from "form-data"; +// typings of url-parse are incorrect... +// @ts-ignore +import * as URLParse from "url-parse"; +import { Observable, from } from '../rxjsStub'; + +export * from './isomorphic-fetch'; + +/** + * Represents an HTTP method. + */ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +/** + * Represents an HTTP file which will be transferred from or to a server. + */ +export type HttpFile = { + data: Buffer, + name: string +}; + + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +/** + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData; + +/** + * Represents an HTTP request context + */ +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: RequestBody = undefined; + private url: URLParse; + + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = URLParse(url, true); + } + + /* + * Returns the url set in the constructor including the query string + * + */ + public getUrl(): string { + return this.url.toString(); + } + + /** + * Replaces the url set in the constructor with this url. + * + */ + public setUrl(url: string) { + this.url = URLParse(url, true); + } + + /** + * Sets the body of the http request either as a string or FormData + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 + * + * @param body the body of the request + */ + public setBody(body: RequestBody) { + this.body = body; + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): RequestBody { + return this.body; + } + + public setQueryParam(name: string, value: string) { + let queryObj = this.url.query; + queryObj[name] = value; + this.url.set("query", queryObj); + } + + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } +} + +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; + } +} + +export interface HttpLibrary { + send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/http/isomorphic-fetch.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/http/isomorphic-fetch.ts new file mode 100644 index 000000000000..ed390df7ce10 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/http/isomorphic-fetch.ts @@ -0,0 +1,31 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import { from, Observable } from '../rxjsStub'; +import fetch from "node-fetch"; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + const resultPromise = fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + }).then((resp: any) => { + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; + }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); + }); + + return from>(resultPromise); + + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts new file mode 100644 index 000000000000..25bd41db1a85 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/index.ts @@ -0,0 +1,14 @@ +import "es6-promise/auto"; + +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration, Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; + +export { PromiseMiddleware as Middleware } from './middleware'; +export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; + +export * from "./services/index"; +export { AbstractPromisePetApi as AbstractPetApi, AbstractPromiseStoreApi as AbstractStoreApi, AbstractPromiseUserApi as AbstractUserApi } from './services/PromiseAPI'; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/middleware.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/middleware.ts new file mode 100644 index 000000000000..46da5d25ef07 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/middleware.ts @@ -0,0 +1,66 @@ +import {RequestContext, ResponseContext} from './http/http'; +import { Observable, from } from './rxjsStub'; + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Promise; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Promise; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts new file mode 100644 index 000000000000..300b2de4d9a9 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts @@ -0,0 +1,52 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Describes the result of uploading an image resource +*/ +export class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "number", + "format": "int32" + }, + { + "name": "type", + "baseName": "type", + "type": "string", + "format": "" + }, + { + "name": "message", + "baseName": "message", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ApiResponse.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts new file mode 100644 index 000000000000..9b210d5d501d --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts @@ -0,0 +1,45 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A category for a pet +*/ +export class Category { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Category.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject.ts new file mode 100644 index 000000000000..54192c1c8356 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject { + /** + * Updated name of the pet + */ + 'name'?: string; + /** + * Updated status of the pet + */ + 'status'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return InlineObject.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject1.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject1.ts new file mode 100644 index 000000000000..02e988674a08 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/InlineObject1.ts @@ -0,0 +1,48 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class InlineObject1 { + /** + * Additional data to pass to server + */ + 'additionalMetadata'?: string; + /** + * file to upload + */ + 'file'?: HttpFile; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "additionalMetadata", + "baseName": "additionalMetadata", + "type": "string", + "format": "" + }, + { + "name": "file", + "baseName": "file", + "type": "HttpFile", + "format": "binary" + } ]; + + static getAttributeTypeMap() { + return InlineObject1.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts new file mode 100644 index 000000000000..f485b39e42b3 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts @@ -0,0 +1,240 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './InlineObject'; +export * from './InlineObject1'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + +import { ApiResponse } from './ApiResponse'; +import { Category } from './Category'; +import { InlineObject } from './InlineObject'; +import { InlineObject1 } from './InlineObject1'; +import { Order , OrderStatusEnum } from './Order'; +import { Pet , PetStatusEnum } from './Pet'; +import { Tag } from './Tag'; +import { User } from './User'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + + +let enumsMap: Set = new Set([ + "OrderStatusEnum", + "PetStatusEnum", +]); + +let typeMap: {[index: string]: any} = { + "ApiResponse": ApiResponse, + "Category": Category, + "InlineObject": InlineObject, + "InlineObject1": InlineObject1, + "Order": Order, + "Pet": Pet, + "Tag": Tag, + "User": User, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap.has(expectedType)) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string, format: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + if (format == "date") { + let month = data.getMonth()+1 + month = month < 10 ? "0" + month.toString() : month.toString() + let day = data.getDate(); + day = day < 10 ? "0" + day.toString() : day.toString(); + + return data.getFullYear() + "-" + month + "-" + day; + } else { + return data.toISOString(); + } + } else { + if (enumsMap.has(type)) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); + } + return instance; + } + } + + public static deserialize(data: any, type: string, format: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap.has(type)) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); + } + return instance; + } + } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts new file mode 100644 index 000000000000..291018b9e065 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts @@ -0,0 +1,79 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* An order for a pets from the pet store +*/ +export class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; + /** + * Order Status + */ + 'status'?: OrderStatusEnum; + 'complete'?: boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number", + "format": "int64" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number", + "format": "int32" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date", + "format": "date-time" + }, + { + "name": "status", + "baseName": "status", + "type": "OrderStatusEnum", + "format": "" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Order.attributeTypeMap; + } + + public constructor() { + } +} + + +export type OrderStatusEnum = "placed" | "approved" | "delivered" ; + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts new file mode 100644 index 000000000000..77a3490297db --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts @@ -0,0 +1,81 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { Category } from './Category'; +import { Tag } from './Tag'; +import { HttpFile } from '../http/http'; + +/** +* A pet for sale in the pet store +*/ +export class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; + /** + * pet status in the store + */ + 'status'?: PetStatusEnum; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "category", + "baseName": "category", + "type": "Category", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array", + "format": "" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "PetStatusEnum", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Pet.attributeTypeMap; + } + + public constructor() { + } +} + + +export type PetStatusEnum = "available" | "pending" | "sold" ; + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts new file mode 100644 index 000000000000..ce2a0e6d2a80 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts @@ -0,0 +1,45 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A tag for a pet +*/ +export class Tag { + 'id'?: number; + 'name'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return Tag.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts new file mode 100644 index 000000000000..049af95de370 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts @@ -0,0 +1,90 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A User who is purchasing from the pet store +*/ +export class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; + /** + * User Status + */ + 'userStatus'?: number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number", + "format": "int64" + }, + { + "name": "username", + "baseName": "username", + "type": "string", + "format": "" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string", + "format": "" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string", + "format": "" + }, + { + "name": "email", + "baseName": "email", + "type": "string", + "format": "" + }, + { + "name": "password", + "baseName": "password", + "type": "string", + "format": "" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string", + "format": "" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return User.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/all.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/all.ts new file mode 100644 index 000000000000..d064eba93abd --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/all.ts @@ -0,0 +1,8 @@ +export * from './ApiResponse' +export * from './Category' +export * from './InlineObject' +export * from './InlineObject1' +export * from './Order' +export * from './Pet' +export * from './Tag' +export * from './User' diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/inversify/package-lock.json new file mode 100644 index 000000000000..133d18033983 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/package-lock.json @@ -0,0 +1,120 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.11.tgz", + "integrity": "sha512-lCvvI24L21ZVeIiyIUHZ5Oflv1hhHQ5E1S25IRlKIXaRkVgmXpJMI3wUJkmym2bTbCe+WoIibQnMVAU3FguaOg==" + }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "inversify": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/inversify/-/inversify-5.0.1.tgz", + "integrity": "sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ==" + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "querystringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "typescript": { + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", + "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", + "dev": true + }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + } + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/package.json b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json new file mode 100644 index 000000000000..61af027719c1 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/package.json @@ -0,0 +1,32 @@ +{ + "name": "ts-petstore-client", + "version": "1.0.0", + "description": "OpenAPI client for ts-petstore-client", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "fetch", + "typescript", + "openapi-client", + "openapi-generator" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", + "@types/node": "*", + "form-data": "^2.5.0", + "btoa": "^1.2.1", + "inversify": "^5.0.1", + "es6-promise": "^4.2.4", + "url-parse": "^1.4.3" + }, + "devDependencies": { + "typescript": "^3.9.3" + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/pom.xml b/samples/openapi3/client/petstore/typescript/builds/inversify/pom.xml new file mode 100644 index 000000000000..9f19515eb5fb --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + org.openapitools + TypeScriptBuildInversifyPetstoreClientSample + pom + 1.0-SNAPSHOT + TS Inversify Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-build + pre-integration-test + + exec + + + npm + + run + build + + + + + + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/rxjsStub.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/rxjsStub.ts new file mode 100644 index 000000000000..4c73715a2486 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/servers.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/servers.ts new file mode 100644 index 000000000000..aa5332db7ae9 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/servers.ts @@ -0,0 +1,53 @@ +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} + +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration implements BaseServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); + } + return replacedUrl + } + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.getUrl() + endpoint, httpMethod); + } +} + +export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) + +export const servers = [server1]; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObjectParamAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObjectParamAPI.ts new file mode 100644 index 000000000000..c3bff4dceeac --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObjectParamAPI.ts @@ -0,0 +1,153 @@ +import type { HttpFile } from '../http/http'; +import type { Configuration } from '../configuration' +import type * as req from "../types/ObjectParamAPI"; + +import type { ApiResponse } from '../models/ApiResponse'; +import type { Category } from '../models/Category'; +import type { InlineObject } from '../models/InlineObject'; +import type { InlineObject1 } from '../models/InlineObject1'; +import type { Order } from '../models/Order'; +import type { Pet } from '../models/Pet'; +import type { Tag } from '../models/Tag'; +import type { User } from '../models/User'; + + +export abstract class AbstractObjectPetApi { + /** + * Add a new pet to the store + * @param param the request object + */ + public abstract addPet(param: req.PetApiAddPetRequest, options?: Configuration): Promise; + + /** + * Deletes a pet + * @param param the request object + */ + public abstract deletePet(param: req.PetApiDeletePetRequest, options?: Configuration): Promise; + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param param the request object + */ + public abstract findPetsByStatus(param: req.PetApiFindPetsByStatusRequest, options?: Configuration): Promise>; + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param param the request object + */ + public abstract findPetsByTags(param: req.PetApiFindPetsByTagsRequest, options?: Configuration): Promise>; + + /** + * Returns a single pet + * Find pet by ID + * @param param the request object + */ + public abstract getPetById(param: req.PetApiGetPetByIdRequest, options?: Configuration): Promise; + + /** + * Update an existing pet + * @param param the request object + */ + public abstract updatePet(param: req.PetApiUpdatePetRequest, options?: Configuration): Promise; + + /** + * Updates a pet in the store with form data + * @param param the request object + */ + public abstract updatePetWithForm(param: req.PetApiUpdatePetWithFormRequest, options?: Configuration): Promise; + + /** + * uploads an image + * @param param the request object + */ + public abstract uploadFile(param: req.PetApiUploadFileRequest, options?: Configuration): Promise; + +} + + +export abstract class AbstractObjectStoreApi { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param param the request object + */ + public abstract deleteOrder(param: req.StoreApiDeleteOrderRequest, options?: Configuration): Promise; + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + * @param param the request object + */ + public abstract getInventory(param: req.StoreApiGetInventoryRequest, options?: Configuration): Promise<{ [key: string]: number; }>; + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param param the request object + */ + public abstract getOrderById(param: req.StoreApiGetOrderByIdRequest, options?: Configuration): Promise; + + /** + * Place an order for a pet + * @param param the request object + */ + public abstract placeOrder(param: req.StoreApiPlaceOrderRequest, options?: Configuration): Promise; + +} + + +export abstract class AbstractObjectUserApi { + /** + * This can only be done by the logged in user. + * Create user + * @param param the request object + */ + public abstract createUser(param: req.UserApiCreateUserRequest, options?: Configuration): Promise; + + /** + * Creates list of users with given input array + * @param param the request object + */ + public abstract createUsersWithArrayInput(param: req.UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise; + + /** + * Creates list of users with given input array + * @param param the request object + */ + public abstract createUsersWithListInput(param: req.UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise; + + /** + * This can only be done by the logged in user. + * Delete user + * @param param the request object + */ + public abstract deleteUser(param: req.UserApiDeleteUserRequest, options?: Configuration): Promise; + + /** + * Get user by user name + * @param param the request object + */ + public abstract getUserByName(param: req.UserApiGetUserByNameRequest, options?: Configuration): Promise; + + /** + * Logs user into the system + * @param param the request object + */ + public abstract loginUser(param: req.UserApiLoginUserRequest, options?: Configuration): Promise; + + /** + * Logs out current logged in user session + * @param param the request object + */ + public abstract logoutUser(param: req.UserApiLogoutUserRequest, options?: Configuration): Promise; + + /** + * This can only be done by the logged in user. + * Updated user + * @param param the request object + */ + public abstract updateUser(param: req.UserApiUpdateUserRequest, options?: Configuration): Promise; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObservableAPI.ts new file mode 100644 index 000000000000..346900cc554a --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/ObservableAPI.ts @@ -0,0 +1,64 @@ +import type { HttpFile } from "../http/http"; +import type { Observable } from "../rxjsStub"; +import type { Configuration } from "../configuration"; + +import { ApiResponse } from "../models/ApiResponse"; +import { Category } from "../models/Category"; +import { InlineObject } from "../models/InlineObject"; +import { InlineObject1 } from "../models/InlineObject1"; +import { Order } from "../models/Order"; +import { Pet } from "../models/Pet"; +import { Tag } from "../models/Tag"; +import { User } from "../models/User"; + + +export abstract class AbstractObservablePetApi { + public abstract addPet(pet: Pet, options?: Configuration): Observable; + + public abstract deletePet(petId: number, apiKey?: string, options?: Configuration): Observable; + + public abstract findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable>; + + public abstract findPetsByTags(tags: Array, options?: Configuration): Observable>; + + public abstract getPetById(petId: number, options?: Configuration): Observable; + + public abstract updatePet(pet: Pet, options?: Configuration): Observable; + + public abstract updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable; + + public abstract uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable; + +} + + +export abstract class AbstractObservableStoreApi { + public abstract deleteOrder(orderId: string, options?: Configuration): Observable; + + public abstract getInventory(options?: Configuration): Observable<{ [key: string]: number; }>; + + public abstract getOrderById(orderId: number, options?: Configuration): Observable; + + public abstract placeOrder(order: Order, options?: Configuration): Observable; + +} + + +export abstract class AbstractObservableUserApi { + public abstract createUser(user: User, options?: Configuration): Observable; + + public abstract createUsersWithArrayInput(user: Array, options?: Configuration): Observable; + + public abstract createUsersWithListInput(user: Array, options?: Configuration): Observable; + + public abstract deleteUser(username: string, options?: Configuration): Observable; + + public abstract getUserByName(username: string, options?: Configuration): Observable; + + public abstract loginUser(username: string, password: string, options?: Configuration): Observable; + + public abstract logoutUser(options?: Configuration): Observable; + + public abstract updateUser(username: string, user: User, options?: Configuration): Observable; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/PromiseAPI.ts new file mode 100644 index 000000000000..365741814d38 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/PromiseAPI.ts @@ -0,0 +1,63 @@ +import type { HttpFile } from "../http/http"; +import type { Configuration } from "../configuration"; + +import { ApiResponse } from "../models/ApiResponse"; +import { Category } from "../models/Category"; +import { InlineObject } from "../models/InlineObject"; +import { InlineObject1 } from "../models/InlineObject1"; +import { Order } from "../models/Order"; +import { Pet } from "../models/Pet"; +import { Tag } from "../models/Tag"; +import { User } from "../models/User"; + + +export abstract class AbstractPromisePetApi { + public abstract addPet(pet: Pet, options?: Configuration): Promise; + + public abstract deletePet(petId: number, apiKey?: string, options?: Configuration): Promise; + + public abstract findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise>; + + public abstract findPetsByTags(tags: Array, options?: Configuration): Promise>; + + public abstract getPetById(petId: number, options?: Configuration): Promise; + + public abstract updatePet(pet: Pet, options?: Configuration): Promise; + + public abstract updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise; + + public abstract uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise; + +} + + +export abstract class AbstractPromiseStoreApi { + public abstract deleteOrder(orderId: string, options?: Configuration): Promise; + + public abstract getInventory(options?: Configuration): Promise<{ [key: string]: number; }>; + + public abstract getOrderById(orderId: number, options?: Configuration): Promise; + + public abstract placeOrder(order: Order, options?: Configuration): Promise; + +} + + +export abstract class AbstractPromiseUserApi { + public abstract createUser(user: User, options?: Configuration): Promise; + + public abstract createUsersWithArrayInput(user: Array, options?: Configuration): Promise; + + public abstract createUsersWithListInput(user: Array, options?: Configuration): Promise; + + public abstract deleteUser(username: string, options?: Configuration): Promise; + + public abstract getUserByName(username: string, options?: Configuration): Promise; + + public abstract loginUser(username: string, password: string, options?: Configuration): Promise; + + public abstract logoutUser(options?: Configuration): Promise; + + public abstract updateUser(username: string, user: User, options?: Configuration): Promise; + +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/configuration.ts new file mode 100644 index 000000000000..06e8dc992fcc --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/configuration.ts @@ -0,0 +1,21 @@ +import type { AbstractServerConfiguration } from "./http"; +import type { HttpLibrary, RequestContext } from "../http/http"; +import type { Middleware } from "../middleware"; +import type { AuthMethods, TokenProvider } from "../auth/auth"; +import type { Configuration } from "../configuration"; + +export abstract class AbstractConfiguration implements Configuration { + abstract get baseServer(): AbstractServerConfiguration; + abstract get httpApi(): HttpLibrary; + abstract get middleware(): Middleware[]; + abstract get authMethods(): AuthMethods; +} + +export abstract class AbstractAuthMethod { + public abstract getName(): string; + public abstract applySecurityAuthentication(context: RequestContext): void | Promise; +}; + +export abstract class AbstractTokenProvider implements TokenProvider { + public abstract getToken(): string | Promise; +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/http.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/http.ts new file mode 100644 index 000000000000..a84fc3f5dec1 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/http.ts @@ -0,0 +1,17 @@ +import type { PromiseHttpLibrary, HttpMethod, RequestContext, ResponseContext } from "../http/http"; +import type { PromiseMiddleware } from "../middleware"; +import type { BaseServerConfiguration } from "../servers"; + +export abstract class AbstractHttpLibrary implements PromiseHttpLibrary { + public abstract send(request: RequestContext): Promise; +}; + +export abstract class AbstractMiddleware implements PromiseMiddleware { + public abstract pre(context: RequestContext): Promise; + public abstract post(context: ResponseContext): Promise; +} + +export abstract class AbstractServerConfiguration implements BaseServerConfiguration { + public abstract makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +}; + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/services/index.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/services/index.ts new file mode 100644 index 000000000000..6d51d98048a3 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/services/index.ts @@ -0,0 +1,126 @@ +import { inject, injectable, multiInject, optional, interfaces } from "inversify"; + +import { Configuration } from "../configuration"; +import { ServerConfiguration, servers } from "../servers"; +import { HttpLibrary, wrapHttpLibrary } from "../http/http"; +import { Middleware, PromiseMiddlewareWrapper } from "../middleware"; +import { authMethodServices, AuthMethods } from "../auth/auth"; + +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "../http/isomorphic-fetch"; + +import { AbstractHttpLibrary, AbstractMiddleware, AbstractServerConfiguration } from "./http"; +import { AbstractConfiguration, AbstractAuthMethod, AbstractTokenProvider } from "./configuration"; + +export { AbstractHttpLibrary, AbstractMiddleware, AbstractServerConfiguration, AbstractConfiguration, AbstractAuthMethod, AbstractTokenProvider }; + +import * as apis from "../types/PromiseAPI"; +import * as apiServices from "./PromiseAPI"; + +@injectable() +class InjectableConfiguration implements AbstractConfiguration { + public httpApi: HttpLibrary = new DefaultHttpLibrary(); + public middleware: Middleware[] = []; + public authMethods: AuthMethods = {}; + + constructor( + @inject(AbstractServerConfiguration) @optional() public baseServer: AbstractServerConfiguration = servers[0], + @inject(AbstractHttpLibrary) @optional() httpApi: AbstractHttpLibrary, + @multiInject(AbstractMiddleware) @optional() middleware: AbstractMiddleware[] = [], + @multiInject(AbstractAuthMethod) @optional() securityConfiguration: AbstractAuthMethod[] = [] + ) { + this.httpApi = httpApi === undefined ? new DefaultHttpLibrary() : wrapHttpLibrary(httpApi); + for (const _middleware of middleware) { + this.middleware.push(new PromiseMiddlewareWrapper(_middleware)); + } + for (const authMethod of securityConfiguration) { + const authName = authMethod.getName(); + // @ts-ignore + if (authMethodServices[authName] !== undefined) { + // @ts-ignore + this.authMethods[authName] = authMethod; + } + } + } +} + +/** + * Helper class to simplify binding the services + */ +export class ApiServiceBinder { + constructor(private container: interfaces.Container) { + this.container.bind(AbstractConfiguration).to(InjectableConfiguration); + } + + /** + * Allows you to bind a server configuration without having to import the service identifier. + */ + public get bindServerConfiguration() { + return this.container.bind(AbstractServerConfiguration); + } + + /** + * Use one of the predefined server configurations. + * + * To customize the server variables you can call `setVariables` on the + * return value; + */ + public bindServerConfigurationToPredefined(idx: number) { + this.bindServerConfiguration.toConstantValue(servers[idx]); + return servers[idx]; + } + + /** + * Explicitly define the service base url + */ + public bindServerConfigurationToURL(url: string) { + return this.bindServerConfiguration.toConstantValue( + new ServerConfiguration<{}>(url, {}) + ); + } + + /** + * Allows you to bind a http library without having to import the service identifier. + */ + public get bindHttpLibrary() { + return this.container.bind(AbstractHttpLibrary); + } + + /** + * Allows you to bind a middleware without having to import the service identifier. + * + * You can bind multiple middlewares by calling this multiple method times. + */ + public get bindMiddleware() { + return this.container.bind(AbstractMiddleware); + } + + /** + * Allows you to bind an auth method without having to import the service identifier. + * + * Note: The name of the bound auth method needs to be known in the specs, + * because the name is used to decide for which endpoints to apply the authentication. + */ + public get bindAuthMethod() { + return this.container.bind(AbstractAuthMethod); + } + + /** + * Use one of the predefined auth methods. + * + * Make sure that you have injected all dependencies for it. + */ + public bindAuthMethodToPredefined(name: keyof AuthMethods) { + return this.bindAuthMethod.to(authMethodServices[name]); + } + + /** + * Bind all the apis to their respective service identifiers + * + * If you want to only bind some of the apis, you need to do that manually. + */ + public bindAllApiServices() { + this.container.bind(apiServices.AbstractPromisePetApi).to(apis.PromisePetApi).inSingletonScope(); + this.container.bind(apiServices.AbstractPromiseStoreApi).to(apis.PromiseStoreApi).inSingletonScope(); + this.container.bind(apiServices.AbstractPromiseUserApi).to(apis.PromiseUserApi).inSingletonScope(); + } +} diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json new file mode 100644 index 000000000000..b53dce7b41b3 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + + /* Additional Checks */ + "noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!) + "noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "lib": [ "es6" ], + "experimentalDecorators": true, + }, + "exclude": [ + "dist", + "node_modules" + ], + "filesGlob": [ + "./**/*.ts", + ] + +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObjectParamAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObjectParamAPI.ts new file mode 100644 index 000000000000..10cebbd77dd2 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObjectParamAPI.ts @@ -0,0 +1,442 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { ObservablePetApi } from "./ObservableAPI"; +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; + +export interface PetApiAddPetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiaddPet + */ + pet: Pet +} + +export interface PetApiDeletePetRequest { + /** + * Pet id to delete + * @type number + * @memberof PetApideletePet + */ + petId: number + /** + * + * @type string + * @memberof PetApideletePet + */ + apiKey?: string +} + +export interface PetApiFindPetsByStatusRequest { + /** + * Status values that need to be considered for filter + * @type Array<'available' | 'pending' | 'sold'> + * @memberof PetApifindPetsByStatus + */ + status: Array<'available' | 'pending' | 'sold'> +} + +export interface PetApiFindPetsByTagsRequest { + /** + * Tags to filter by + * @type Array<string> + * @memberof PetApifindPetsByTags + */ + tags: Array +} + +export interface PetApiGetPetByIdRequest { + /** + * ID of pet to return + * @type number + * @memberof PetApigetPetById + */ + petId: number +} + +export interface PetApiUpdatePetRequest { + /** + * Pet object that needs to be added to the store + * @type Pet + * @memberof PetApiupdatePet + */ + pet: Pet +} + +export interface PetApiUpdatePetWithFormRequest { + /** + * ID of pet that needs to be updated + * @type number + * @memberof PetApiupdatePetWithForm + */ + petId: number + /** + * Updated name of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + name?: string + /** + * Updated status of the pet + * @type string + * @memberof PetApiupdatePetWithForm + */ + status?: string +} + +export interface PetApiUploadFileRequest { + /** + * ID of pet to update + * @type number + * @memberof PetApiuploadFile + */ + petId: number + /** + * Additional data to pass to server + * @type string + * @memberof PetApiuploadFile + */ + additionalMetadata?: string + /** + * file to upload + * @type HttpFile + * @memberof PetApiuploadFile + */ + file?: HttpFile +} + + +export class ObjectPetApi { + private api: ObservablePetApi + + public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param param the request object + */ + public addPet(param: PetApiAddPetRequest, options?: Configuration): Promise { + return this.api.addPet(param.pet, options).toPromise(); + } + + /** + * Deletes a pet + * @param param the request object + */ + public deletePet(param: PetApiDeletePetRequest, options?: Configuration): Promise { + return this.api.deletePet(param.petId, param.apiKey, options).toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param param the request object + */ + public findPetsByStatus(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise> { + return this.api.findPetsByStatus(param.status, options).toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param param the request object + */ + public findPetsByTags(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise> { + return this.api.findPetsByTags(param.tags, options).toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param param the request object + */ + public getPetById(param: PetApiGetPetByIdRequest, options?: Configuration): Promise { + return this.api.getPetById(param.petId, options).toPromise(); + } + + /** + * Update an existing pet + * @param param the request object + */ + public updatePet(param: PetApiUpdatePetRequest, options?: Configuration): Promise { + return this.api.updatePet(param.pet, options).toPromise(); + } + + /** + * Updates a pet in the store with form data + * @param param the request object + */ + public updatePetWithForm(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise { + return this.api.updatePetWithForm(param.petId, param.name, param.status, options).toPromise(); + } + + /** + * uploads an image + * @param param the request object + */ + public uploadFile(param: PetApiUploadFileRequest, options?: Configuration): Promise { + return this.api.uploadFile(param.petId, param.additionalMetadata, param.file, options).toPromise(); + } + + +} + + + + +import { ObservableStoreApi } from "./ObservableAPI"; +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; + +export interface StoreApiDeleteOrderRequest { + /** + * ID of the order that needs to be deleted + * @type string + * @memberof StoreApideleteOrder + */ + orderId: string +} + +export interface StoreApiGetInventoryRequest { +} + +export interface StoreApiGetOrderByIdRequest { + /** + * ID of pet that needs to be fetched + * @type number + * @memberof StoreApigetOrderById + */ + orderId: number +} + +export interface StoreApiPlaceOrderRequest { + /** + * order placed for purchasing the pet + * @type Order + * @memberof StoreApiplaceOrder + */ + order: Order +} + + +export class ObjectStoreApi { + private api: ObservableStoreApi + + public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param param the request object + */ + public deleteOrder(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise { + return this.api.deleteOrder(param.orderId, options).toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + * @param param the request object + */ + public getInventory(param: StoreApiGetInventoryRequest, options?: Configuration): Promise<{ [key: string]: number; }> { + return this.api.getInventory( options).toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param param the request object + */ + public getOrderById(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise { + return this.api.getOrderById(param.orderId, options).toPromise(); + } + + /** + * Place an order for a pet + * @param param the request object + */ + public placeOrder(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise { + return this.api.placeOrder(param.order, options).toPromise(); + } + + +} + + + + +import { ObservableUserApi } from "./ObservableAPI"; +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; + +export interface UserApiCreateUserRequest { + /** + * Created user object + * @type User + * @memberof UserApicreateUser + */ + user: User +} + +export interface UserApiCreateUsersWithArrayInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithArrayInput + */ + user: Array +} + +export interface UserApiCreateUsersWithListInputRequest { + /** + * List of user object + * @type Array<User> + * @memberof UserApicreateUsersWithListInput + */ + user: Array +} + +export interface UserApiDeleteUserRequest { + /** + * The name that needs to be deleted + * @type string + * @memberof UserApideleteUser + */ + username: string +} + +export interface UserApiGetUserByNameRequest { + /** + * The name that needs to be fetched. Use user1 for testing. + * @type string + * @memberof UserApigetUserByName + */ + username: string +} + +export interface UserApiLoginUserRequest { + /** + * The user name for login + * @type string + * @memberof UserApiloginUser + */ + username: string + /** + * The password for login in clear text + * @type string + * @memberof UserApiloginUser + */ + password: string +} + +export interface UserApiLogoutUserRequest { +} + +export interface UserApiUpdateUserRequest { + /** + * name that need to be deleted + * @type string + * @memberof UserApiupdateUser + */ + username: string + /** + * Updated user object + * @type User + * @memberof UserApiupdateUser + */ + user: User +} + + +export class ObjectUserApi { + private api: ObservableUserApi + + public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param param the request object + */ + public createUser(param: UserApiCreateUserRequest, options?: Configuration): Promise { + return this.api.createUser(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithArrayInput(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithArrayInput(param.user, options).toPromise(); + } + + /** + * Creates list of users with given input array + * @param param the request object + */ + public createUsersWithListInput(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise { + return this.api.createUsersWithListInput(param.user, options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param param the request object + */ + public deleteUser(param: UserApiDeleteUserRequest, options?: Configuration): Promise { + return this.api.deleteUser(param.username, options).toPromise(); + } + + /** + * Get user by user name + * @param param the request object + */ + public getUserByName(param: UserApiGetUserByNameRequest, options?: Configuration): Promise { + return this.api.getUserByName(param.username, options).toPromise(); + } + + /** + * Logs user into the system + * @param param the request object + */ + public loginUser(param: UserApiLoginUserRequest, options?: Configuration): Promise { + return this.api.loginUser(param.username, param.password, options).toPromise(); + } + + /** + * Logs out current logged in user session + * @param param the request object + */ + public logoutUser(param: UserApiLogoutUserRequest, options?: Configuration): Promise { + return this.api.logoutUser( options).toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param param the request object + */ + public updateUser(param: UserApiUpdateUserRequest, options?: Configuration): Promise { + return this.api.updateUser(param.username, param.user, options).toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts new file mode 100644 index 000000000000..58b8d97c3e07 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/ObservableAPI.ts @@ -0,0 +1,565 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { Observable, of, from } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() +export class ObservablePetApi { + private requestFactory: AbstractPetApiRequestFactory; + private responseProcessor: AbstractPetApiResponseProcessor; + private configuration: Configuration; + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public addPet(pet: Pet, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.addPet(pet, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp))); + })); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp))); + })); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.findPetsByStatus(status, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp))); + })); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Observable> { + const requestContextPromise = this.requestFactory.findPetsByTags(tags, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp))); + })); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getPetById(petId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp))); + })); + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public updatePet(pet: Pet, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updatePet(pet, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp))); + })); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp))); + })); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp))); + })); + } + + +} + + + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() +export class ObservableStoreApi { + private requestFactory: AbstractStoreApiRequestFactory; + private responseProcessor: AbstractStoreApiResponseProcessor; + private configuration: Configuration; + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deleteOrder(orderId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp))); + })); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> { + const requestContextPromise = this.requestFactory.getInventory(options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp))); + })); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getOrderById(orderId, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp))); + })); + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public placeOrder(order: Order, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.placeOrder(order, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp))); + })); + } + + +} + + + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() +export class ObservableUserApi { + private requestFactory: AbstractUserApiRequestFactory; + private responseProcessor: AbstractUserApiResponseProcessor; + private configuration: Configuration; + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public createUser(user: User, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUser(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithArrayInput(user: Array, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp))); + })); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithListInput(user: Array, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.deleteUser(username, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp))); + })); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getUserByName(username, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp))); + })); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.loginUser(username, password, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp))); + })); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.logoutUser(options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp))); + })); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public updateUser(username: string, user: User, options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.updateUser(username, user, options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp))); + })); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts new file mode 100644 index 000000000000..7719a5f77b34 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/types/PromiseAPI.ts @@ -0,0 +1,277 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import * as models from '../models/all'; +import { Configuration} from '../configuration' +import { injectable, inject, optional } from "inversify"; +import { AbstractConfiguration } from "../services/configuration"; + +import { ApiResponse } from '../models/ApiResponse'; +import { Category } from '../models/Category'; +import { InlineObject } from '../models/InlineObject'; +import { InlineObject1 } from '../models/InlineObject1'; +import { Order } from '../models/Order'; +import { Pet } from '../models/Pet'; +import { Tag } from '../models/Tag'; +import { User } from '../models/User'; +import { ObservablePetApi } from './ObservableAPI'; + + +import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; +import { AbstractPetApiRequestFactory, AbstractPetApiResponseProcessor } from "../apis/PetApi.service"; + +@injectable() +export class PromisePetApi { + private api: ObservablePetApi + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractPetApiRequestFactory) @optional() requestFactory?: AbstractPetApiRequestFactory, + @inject(AbstractPetApiResponseProcessor) @optional() responseProcessor?: AbstractPetApiResponseProcessor + ) { + this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); + } + + /** + * Add a new pet to the store + * @param pet Pet object that needs to be added to the store + */ + public addPet(pet: Pet, options?: Configuration): Promise { + const result = this.api.addPet(pet, options); + return result.toPromise(); + } + + /** + * Deletes a pet + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise { + const result = this.api.deletePet(petId, apiKey, options); + return result.toPromise(); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise> { + const result = this.api.findPetsByStatus(status, options); + return result.toPromise(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, options?: Configuration): Promise> { + const result = this.api.findPetsByTags(tags, options); + return result.toPromise(); + } + + /** + * Returns a single pet + * Find pet by ID + * @param petId ID of pet to return + */ + public getPetById(petId: number, options?: Configuration): Promise { + const result = this.api.getPetById(petId, options); + return result.toPromise(); + } + + /** + * Update an existing pet + * @param pet Pet object that needs to be added to the store + */ + public updatePet(pet: Pet, options?: Configuration): Promise { + const result = this.api.updatePet(pet, options); + return result.toPromise(); + } + + /** + * 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: number, name?: string, status?: string, options?: Configuration): Promise { + const result = this.api.updatePetWithForm(petId, name, status, options); + return result.toPromise(); + } + + /** + * uploads an image + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise { + const result = this.api.uploadFile(petId, additionalMetadata, file, options); + return result.toPromise(); + } + + +} + + + +import { ObservableStoreApi } from './ObservableAPI'; + + +import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; +import { AbstractStoreApiRequestFactory, AbstractStoreApiResponseProcessor } from "../apis/StoreApi.service"; + +@injectable() +export class PromiseStoreApi { + private api: ObservableStoreApi + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractStoreApiRequestFactory) @optional() requestFactory?: AbstractStoreApiRequestFactory, + @inject(AbstractStoreApiResponseProcessor) @optional() responseProcessor?: AbstractStoreApiResponseProcessor + ) { + this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, options?: Configuration): Promise { + const result = this.api.deleteOrder(orderId, options); + return result.toPromise(); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> { + const result = this.api.getInventory(options); + return result.toPromise(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, options?: Configuration): Promise { + const result = this.api.getOrderById(orderId, options); + return result.toPromise(); + } + + /** + * Place an order for a pet + * @param order order placed for purchasing the pet + */ + public placeOrder(order: Order, options?: Configuration): Promise { + const result = this.api.placeOrder(order, options); + return result.toPromise(); + } + + +} + + + +import { ObservableUserApi } from './ObservableAPI'; + + +import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; +import { AbstractUserApiRequestFactory, AbstractUserApiResponseProcessor } from "../apis/UserApi.service"; + +@injectable() +export class PromiseUserApi { + private api: ObservableUserApi + + public constructor( + @inject(AbstractConfiguration) configuration: Configuration, + @inject(AbstractUserApiRequestFactory) @optional() requestFactory?: AbstractUserApiRequestFactory, + @inject(AbstractUserApiResponseProcessor) @optional() responseProcessor?: AbstractUserApiResponseProcessor + ) { + this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); + } + + /** + * This can only be done by the logged in user. + * Create user + * @param user Created user object + */ + public createUser(user: User, options?: Configuration): Promise { + const result = this.api.createUser(user, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithArrayInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithArrayInput(user, options); + return result.toPromise(); + } + + /** + * Creates list of users with given input array + * @param user List of user object + */ + public createUsersWithListInput(user: Array, options?: Configuration): Promise { + const result = this.api.createUsersWithListInput(user, options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Delete user + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, options?: Configuration): Promise { + const result = this.api.deleteUser(username, options); + return result.toPromise(); + } + + /** + * Get user by user name + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, options?: Configuration): Promise { + const result = this.api.getUserByName(username, options); + return result.toPromise(); + } + + /** + * Logs user into the system + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, options?: Configuration): Promise { + const result = this.api.loginUser(username, password, options); + return result.toPromise(); + } + + /** + * Logs out current logged in user session + */ + public logoutUser(options?: Configuration): Promise { + const result = this.api.logoutUser(options); + return result.toPromise(); + } + + /** + * This can only be done by the logged in user. + * Updated user + * @param username name that need to be deleted + * @param user Updated user object + */ + public updateUser(username: string, user: User, options?: Configuration): Promise { + const result = this.api.updateUser(username, user, options); + return result.toPromise(); + } + + +} + + + diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/util.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/util.ts new file mode 100644 index 000000000000..d1888434535c --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/util.ts @@ -0,0 +1,28 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts index 5601b82c3172..2cdf0800f32a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/auth/auth.ts @@ -1,84 +1,21 @@ -import {RequestContext} from '../http/http'; // typings for btoa are incorrect -/** - * Base class for all authentication schemes. - * - */ -export abstract class SecurityAuthentication { - - public constructor(private name: string) { - - } - - /* - * - * @return returns the name of the security authentication as specified in OAI - */ - public getName(): string { - return this.name; - } - - /** - * Applies the authentication scheme to the request context - * - * @params context the request context which should use this authentication scheme - */ - public abstract applySecurityAuthentication(context: RequestContext): void | Promise; - -} +import { RequestContext } from "../http/http"; /** - * Applies an api key to the request context. - * + * Interface authentication schemes. */ -export class APIKeyAuthentication extends SecurityAuthentication { - - /** - * Configures this api key authentication with the necessary properties - * - * @param authName: name of this authentication scheme as specified in the swagger.json - * @param paramName: Parameter name used for the api key - * @param keyLocation: Parameter location, either query, header or cookie. - * @param apiKey: The api key to be used for every request - */ - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - if (this.keyLocation === "header") { - context.setHeaderParam(this.paramName, this.apiKey); - } else if (this.keyLocation === "cookie") { - context.addCookie(this.paramName, this.apiKey); - } else if (this.keyLocation === "query") { - context.setQueryParam(this.paramName, this.apiKey); - } - } -} - +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; -/** - * Applies basic http authentication to a request. - * - */ -export class HttpBasicAuthentication extends SecurityAuthentication { - - /** - * Configures the http authentication with the required details. - * - * - * @param authName name of the authentication scheme as defined in swagger json - * @param username username for http basic authentication - * @param password password for http basic authentication - */ - public constructor(authName: string, private username: string, private password: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - let comb = this.username + ":" + this.password; - context.setHeaderParam("Authorization", "Basic " + btoa(comb)); - } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; } export interface TokenProvider { @@ -86,40 +23,45 @@ export interface TokenProvider { } /** - * Applies http bearer authentication to a request. - * + * Applies apiKey authentication to the request context. */ -export class HttpBearerAuthentication extends SecurityAuthentication { +export class ApiKeyAuthentication implements SecurityAuthentication { /** - * Configures the http authentication with the required details. + * Configures this api key authentication with the necessary properties * - * - * @param authName name of the authentication scheme as defined in openapi specification - * @param tokenProvider service that can provide the up-to-date token when needed + * @param apiKey: The api key to be used for every request */ - public constructor(authName: string, private tokenProvider: TokenProvider) { - super(authName); + public constructor(private apiKey: string) {} + + public getName(): string { + return "api_key"; } - public async applySecurityAuthentication(context: RequestContext) { - context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + public applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("api_key", this.apiKey); } } -// TODO: How to handle oauth2 authentication! -export class OAuth2Authentication extends SecurityAuthentication { - public constructor(authName: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - // TODO - } +/** + * Applies oauth2 authentication to the request context. + */ +export class PetstoreAuthAuthentication implements SecurityAuthentication { + // TODO: How to handle oauth2 authentication! + public constructor() {} + + public getName(): string { + return "petstore_auth"; + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } } + export type AuthMethods = { - "api_key"?: APIKeyAuthentication, - "petstore_auth"?: OAuth2Authentication, + "api_key"?: SecurityAuthentication, + "petstore_auth"?: SecurityAuthentication } export type ApiKeyConfiguration = string; @@ -127,7 +69,10 @@ export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; -export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } +export type AuthMethodsConfiguration = { + "api_key"?: ApiKeyConfiguration, + "petstore_auth"?: OAuth2Configuration +} /** * Creates the authentication methods from a swagger description. @@ -141,12 +86,15 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine } if (config["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); - } + authMethods["api_key"] = new ApiKeyAuthentication( + config["api_key"] + ); + } if (config["petstore_auth"]) { - authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); - } + authMethods["petstore_auth"] = new PetstoreAuthAuthentication( + ); + } - return authMethods; + return authMethods; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts index 9bcc9c16eefc..1ca7b345bc19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/configuration.ts @@ -1,28 +1,35 @@ -import {HttpLibrary} from './http/http'; -import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; -import {JQueryHttpLibrary} from "./http/jquery"; -import {ServerConfiguration, server1} from './servers'; -import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { JQueryHttpLibrary as DefaultHttpLibrary } from "./http/jquery"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + /** - * Inetrface with which a configuration object can be configured. - * + * Interface with which a configuration object can be configured. */ export interface ConfigurationParameters { - /** - * Default server to use - */ - baseServer?: ServerConfiguration; - /** - * HTTP library to use e.g. IsomorphicFetch - */ + /** + * Default server to use + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ httpApi?: HttpLibrary; /** * The middlewares which will be applied to requests and responses */ - middleware?: Middleware[]; // middleware to apply before/after fetch requests + middleware?: Middleware[]; /** - * configures all middlewares using the promise api instead of observables (which Middleware uses) + * Configures all middlewares using the promise api instead of observables (which Middleware uses) */ promiseMiddleware?: PromiseMiddleware[]; /** @@ -31,30 +38,29 @@ export interface ConfigurationParameters { authMethods?: AuthMethodsConfiguration } -export class Configuration { - - baseServer: ServerConfiguration; - httpApi: HttpLibrary; - middleware: Middleware[]; - authMethods: AuthMethods; - - /** - * Creates a new configuration object based on the given configuration. - * If a property is not included in conf, a default is used: - * - baseServer: server1 - * - httpApi: IsomorphicFetchHttpLibrary - * - middleware: [] - * - promiseMiddleware: [] - * - authMethods: {} - * @param conf particial configuration - */ - constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new JQueryHttpLibrary; // TODO: replace with window.fetch if available? - this.middleware = conf.middleware || []; - this.authMethods = configureAuthMethods(conf.authMethods); - if (conf.promiseMiddleware) { - conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); - } +/** + * Configuration factory function + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); } + return configuration; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts index 5b163b2626c9..637e96f38a7f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/http/http.ts @@ -1,7 +1,7 @@ // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from '../rxjsStub'; +import { Observable, from } from '../rxjsStub'; export * from './jquery'; @@ -206,4 +206,16 @@ export class ResponseContext { export interface HttpLibrary { send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts index 994fe9dec6d1..cbc24ba3554d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/index.ts @@ -1,11 +1,12 @@ -import 'es6-promise/auto'; +import "es6-promise/auto"; -export * from './http/http'; -export * from './auth/auth'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './apis/exception'; -export * from './servers'; +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration, Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI'; + diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json index 62a0dba628d6..31fa281aeedb 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/package-lock.json @@ -17,11 +17,6 @@ "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" }, - "btoa": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", - "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" - }, "es6-promise": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts index 2124324986d7..aa5332db7ae9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/servers.ts @@ -1,4 +1,8 @@ -import {RequestContext, HttpMethod} from './http/http'; +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} /** * @@ -6,7 +10,7 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { +export class ServerConfiguration implements BaseServerConfiguration { public constructor(private url: string, private variableConfiguration: T) {} /** @@ -45,3 +49,5 @@ export class ServerConfiguration { } export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) + +export const servers = [server1]; diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json index 142f3fa631a3..ccdcadd55948 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/tsconfig.json @@ -4,6 +4,7 @@ /* Basic Options */ "target": "es5", "module": "commonjs", + "moduleResolution": "node", "declaration": true, /* Additional Checks */ @@ -16,7 +17,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6", "dom" ] + "lib": [ "es6", "dom" ], }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts index 35d8b2c428f7..30be6fff1f82 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/ObservableAPI.ts @@ -15,15 +15,19 @@ import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class ObservablePetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } /** * Add a new pet to the store @@ -225,15 +229,19 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class ObservableStoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -337,15 +345,19 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class ObservableUserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts index 159708737069..44829ca43fa8 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/types/PromiseAPI.ts @@ -16,10 +16,14 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class PromisePetApi { private api: ObservablePetApi - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); - } + } /** * Add a new pet to the store @@ -112,10 +116,14 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class PromiseStoreApi { private api: ObservableStoreApi - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); - } + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -166,10 +174,14 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class PromiseUserApi { private api: ObservableUserApi - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); - } + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts index 8a3686484567..9d59a0a25580 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/auth/auth.ts @@ -1,86 +1,23 @@ -import {RequestContext} from '../http/http'; // typings for btoa are incorrect //@ts-ignore import * as btoa from "btoa"; -/** - * Base class for all authentication schemes. - * - */ -export abstract class SecurityAuthentication { - - public constructor(private name: string) { - - } - - /* - * - * @return returns the name of the security authentication as specified in OAI - */ - public getName(): string { - return this.name; - } - - /** - * Applies the authentication scheme to the request context - * - * @params context the request context which should use this authentication scheme - */ - public abstract applySecurityAuthentication(context: RequestContext): void | Promise; - -} +import { RequestContext } from "../http/http"; /** - * Applies an api key to the request context. - * + * Interface authentication schemes. */ -export class APIKeyAuthentication extends SecurityAuthentication { - - /** - * Configures this api key authentication with the necessary properties - * - * @param authName: name of this authentication scheme as specified in the swagger.json - * @param paramName: Parameter name used for the api key - * @param keyLocation: Parameter location, either query, header or cookie. - * @param apiKey: The api key to be used for every request - */ - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - if (this.keyLocation === "header") { - context.setHeaderParam(this.paramName, this.apiKey); - } else if (this.keyLocation === "cookie") { - context.addCookie(this.paramName, this.apiKey); - } else if (this.keyLocation === "query") { - context.setQueryParam(this.paramName, this.apiKey); - } - } -} - +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; -/** - * Applies basic http authentication to a request. - * - */ -export class HttpBasicAuthentication extends SecurityAuthentication { - - /** - * Configures the http authentication with the required details. - * - * - * @param authName name of the authentication scheme as defined in swagger json - * @param username username for http basic authentication - * @param password password for http basic authentication - */ - public constructor(authName: string, private username: string, private password: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - let comb = this.username + ":" + this.password; - context.setHeaderParam("Authorization", "Basic " + btoa(comb)); - } + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; } export interface TokenProvider { @@ -88,40 +25,45 @@ export interface TokenProvider { } /** - * Applies http bearer authentication to a request. - * + * Applies apiKey authentication to the request context. */ -export class HttpBearerAuthentication extends SecurityAuthentication { +export class ApiKeyAuthentication implements SecurityAuthentication { /** - * Configures the http authentication with the required details. + * Configures this api key authentication with the necessary properties * - * - * @param authName name of the authentication scheme as defined in openapi specification - * @param tokenProvider service that can provide the up-to-date token when needed + * @param apiKey: The api key to be used for every request */ - public constructor(authName: string, private tokenProvider: TokenProvider) { - super(authName); + public constructor(private apiKey: string) {} + + public getName(): string { + return "api_key"; } - public async applySecurityAuthentication(context: RequestContext) { - context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken()); + public applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("api_key", this.apiKey); } } -// TODO: How to handle oauth2 authentication! -export class OAuth2Authentication extends SecurityAuthentication { - public constructor(authName: string) { - super(authName); - } - - public applySecurityAuthentication(context: RequestContext) { - // TODO - } +/** + * Applies oauth2 authentication to the request context. + */ +export class PetstoreAuthAuthentication implements SecurityAuthentication { + // TODO: How to handle oauth2 authentication! + public constructor() {} + + public getName(): string { + return "petstore_auth"; + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } } + export type AuthMethods = { - "api_key"?: APIKeyAuthentication, - "petstore_auth"?: OAuth2Authentication, + "api_key"?: SecurityAuthentication, + "petstore_auth"?: SecurityAuthentication } export type ApiKeyConfiguration = string; @@ -129,7 +71,10 @@ export type HttpBasicConfiguration = { "username": string, "password": string }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; export type OAuth2Configuration = string; -export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } +export type AuthMethodsConfiguration = { + "api_key"?: ApiKeyConfiguration, + "petstore_auth"?: OAuth2Configuration +} /** * Creates the authentication methods from a swagger description. @@ -143,12 +88,15 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine } if (config["api_key"]) { - authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", config["api_key"]); - } + authMethods["api_key"] = new ApiKeyAuthentication( + config["api_key"] + ); + } if (config["petstore_auth"]) { - authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); - } + authMethods["petstore_auth"] = new PetstoreAuthAuthentication( + ); + } - return authMethods; + return authMethods; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts index 73f53c7dd211..b78d85972a4a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/configuration.ts @@ -1,28 +1,35 @@ -import {HttpLibrary} from './http/http'; -import {Middleware, PromiseMiddleware, PromiseMiddlewareWrapper} from './middleware'; -import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; -import {ServerConfiguration, server1} from './servers'; -import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + /** - * Inetrface with which a configuration object can be configured. - * + * Interface with which a configuration object can be configured. */ export interface ConfigurationParameters { - /** - * Default server to use - */ - baseServer?: ServerConfiguration; - /** - * HTTP library to use e.g. IsomorphicFetch - */ + /** + * Default server to use + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch + */ httpApi?: HttpLibrary; /** * The middlewares which will be applied to requests and responses */ - middleware?: Middleware[]; // middleware to apply before/after fetch requests + middleware?: Middleware[]; /** - * configures all middlewares using the promise api instead of observables (which Middleware uses) + * Configures all middlewares using the promise api instead of observables (which Middleware uses) */ promiseMiddleware?: PromiseMiddleware[]; /** @@ -31,30 +38,29 @@ export interface ConfigurationParameters { authMethods?: AuthMethodsConfiguration } -export class Configuration { - - baseServer: ServerConfiguration; - httpApi: HttpLibrary; - middleware: Middleware[]; - authMethods: AuthMethods; - - /** - * Creates a new configuration object based on the given configuration. - * If a property is not included in conf, a default is used: - * - baseServer: server1 - * - httpApi: IsomorphicFetchHttpLibrary - * - middleware: [] - * - promiseMiddleware: [] - * - authMethods: {} - * @param conf particial configuration - */ - constructor(conf: ConfigurationParameters = {}) { - this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1; - this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available? - this.middleware = conf.middleware || []; - this.authMethods = configureAuthMethods(conf.authMethods); - if (conf.promiseMiddleware) { - conf.promiseMiddleware.forEach(m => this.middleware.push(new PromiseMiddlewareWrapper(m))); - } +/** + * Configuration factory function + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); } + return configuration; } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts index 6de17431aa26..ac32e72aa981 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts @@ -3,7 +3,7 @@ import * as FormData from "form-data"; // typings of url-parse are incorrect... // @ts-ignore import * as URLParse from "url-parse"; -import { Observable } from '../rxjsStub'; +import { Observable, from } from '../rxjsStub'; export * from './isomorphic-fetch'; @@ -191,4 +191,16 @@ export class ResponseContext { export interface HttpLibrary { send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } } \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts index 965e8fa64649..810dddcbef2d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/index.ts @@ -1,11 +1,12 @@ -import 'es6-promise/auto'; +import "es6-promise/auto"; -export * from './http/http'; -export * from './auth/auth'; -export * from './models/all'; -export { Configuration} from './configuration' -export * from './apis/exception'; -export * from './servers'; +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration, Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; export { PromiseMiddleware as Middleware } from './middleware'; export { PetApiAddPetRequest, PetApiDeletePetRequest, PetApiFindPetsByStatusRequest, PetApiFindPetsByTagsRequest, PetApiGetPetByIdRequest, PetApiUpdatePetRequest, PetApiUpdatePetWithFormRequest, PetApiUploadFileRequest, ObjectPetApi as PetApi, StoreApiDeleteOrderRequest, StoreApiGetInventoryRequest, StoreApiGetOrderByIdRequest, StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, UserApiCreateUserRequest, UserApiCreateUsersWithArrayInputRequest, UserApiCreateUsersWithListInputRequest, UserApiDeleteUserRequest, UserApiGetUserByNameRequest, UserApiLoginUserRequest, UserApiLogoutUserRequest, UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI'; + diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts index 2124324986d7..aa5332db7ae9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/servers.ts @@ -1,4 +1,8 @@ -import {RequestContext, HttpMethod} from './http/http'; +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} /** * @@ -6,7 +10,7 @@ import {RequestContext, HttpMethod} from './http/http'; * url template and variable configuration based on the url. * */ -export class ServerConfiguration { +export class ServerConfiguration implements BaseServerConfiguration { public constructor(private url: string, private variableConfiguration: T) {} /** @@ -45,3 +49,5 @@ export class ServerConfiguration { } export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }) + +export const servers = [server1]; diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json b/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json index 0f376008e1a6..a542d795677c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/tsconfig.json @@ -4,6 +4,7 @@ /* Basic Options */ "target": "es5", "module": "commonjs", + "moduleResolution": "node", "declaration": true, /* Additional Checks */ @@ -16,7 +17,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6" ] + "lib": [ "es6" ], }, "exclude": [ "dist", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts index 35d8b2c428f7..30be6fff1f82 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/types/ObservableAPI.ts @@ -15,15 +15,19 @@ import { User } from '../models/User'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class ObservablePetApi { - private requestFactory: PetApiRequestFactory; - private responseProcessor: PetApiResponseProcessor; + private requestFactory: PetApiRequestFactory; + private responseProcessor: PetApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new PetApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new PetApiResponseProcessor(); + } /** * Add a new pet to the store @@ -225,15 +229,19 @@ export class ObservablePetApi { import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class ObservableStoreApi { - private requestFactory: StoreApiRequestFactory; - private responseProcessor: StoreApiResponseProcessor; + private requestFactory: StoreApiRequestFactory; + private responseProcessor: StoreApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new StoreApiResponseProcessor(); + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -337,15 +345,19 @@ export class ObservableStoreApi { import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class ObservableUserApi { - private requestFactory: UserApiRequestFactory; - private responseProcessor: UserApiResponseProcessor; + private requestFactory: UserApiRequestFactory; + private responseProcessor: UserApiResponseProcessor; private configuration: Configuration; - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { - this.configuration = configuration; - this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); - this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); - } + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new UserApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new UserApiResponseProcessor(); + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts index 159708737069..44829ca43fa8 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/types/PromiseAPI.ts @@ -16,10 +16,14 @@ import { ObservablePetApi } from './ObservableAPI'; import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi"; export class PromisePetApi { private api: ObservablePetApi - - public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: PetApiRequestFactory, + responseProcessor?: PetApiResponseProcessor + ) { this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor); - } + } /** * Add a new pet to the store @@ -112,10 +116,14 @@ import { ObservableStoreApi } from './ObservableAPI'; import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi"; export class PromiseStoreApi { private api: ObservableStoreApi - - public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: StoreApiRequestFactory, + responseProcessor?: StoreApiResponseProcessor + ) { this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor); - } + } /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -166,10 +174,14 @@ import { ObservableUserApi } from './ObservableAPI'; import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi"; export class PromiseUserApi { private api: ObservableUserApi - - public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) { + + public constructor( + configuration: Configuration, + requestFactory?: UserApiRequestFactory, + responseProcessor?: UserApiResponseProcessor + ) { this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor); - } + } /** * This can only be done by the logged in user. diff --git a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json index f7f699330c09..9baade4dc28f 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/default/package-lock.json @@ -1232,13 +1232,20 @@ "url-parse": "^1.4.3" }, "dependencies": { + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" + }, "@types/node": { "version": "12.12.7", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, "@types/node-fetch": { "version": "2.5.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", "requires": { "@types/node": "*", "form-data": "^3.0.0" @@ -1246,7 +1253,8 @@ "dependencies": { "form-data": { "version": "3.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -1257,70 +1265,96 @@ }, "asynckit": { "version": "0.4.0", - "bundled": true + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "btoa": { "version": "1.2.1", - "bundled": true + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { "version": "1.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "es6-promise": { "version": "4.2.5", - "bundled": true + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" }, "form-data": { "version": "2.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "whatwg-fetch": ">=0.10.0" + } + }, "mime-db": { "version": "1.40.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { "mime-db": "1.40.0" } }, "node-fetch": { "version": "2.6.0", - "bundled": true + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.0", - "bundled": true + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", + "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==" }, "requires-port": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "typescript": { - "version": "3.9.3", - "bundled": true + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" }, "url-parse": { "version": "1.4.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", + "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", "requires": { "querystringify": "^2.0.0", "requires-port": "^1.0.0" } + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } }, diff --git a/samples/openapi3/client/petstore/typescript/tests/default/package.json b/samples/openapi3/client/petstore/typescript/tests/default/package.json index 2de26fc0d717..9db286f9532c 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/package.json +++ b/samples/openapi3/client/petstore/typescript/tests/default/package.json @@ -8,7 +8,6 @@ "ts-petstore-client": "file:../../builds/default" }, "scripts": { - "prepublish": "npm install ../../builds/default && npm run build", "test": "mocha test/**/*.ts -r ts-node/register --timeout 10000", "build": "tsc" }, diff --git a/samples/openapi3/client/petstore/typescript/tests/default/pom.xml b/samples/openapi3/client/petstore/typescript/tests/default/pom.xml index e6135cc7f845..4152f9e3a921 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/pom.xml +++ b/samples/openapi3/client/petstore/typescript/tests/default/pom.xml @@ -39,6 +39,20 @@ + + npm-build + pre-integration-test + + exec + + + npm + + run + build + + + npm-test integration-test diff --git a/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts index 956d91e943a8..35f118994ce8 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/default/test/api/PetApi.test.ts @@ -3,7 +3,7 @@ import * as petstore from 'ts-petstore-client' import { expect, assert } from "chai"; import * as fs from 'fs'; -const configuration = new petstore.Configuration() +const configuration = petstore.createConfiguration() const petApi = new petstore.PetApi(configuration) const tag = new petstore.Tag(); diff --git a/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts b/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts index 7f5b5dc7c991..9a70d3e5baf7 100644 --- a/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/default/test/auth/auth.test.ts @@ -1,5 +1,5 @@ import * as petstore from 'ts-petstore-client'; -import { expect} from "chai"; +import { expect } from "chai"; @@ -8,35 +8,14 @@ describe("Security Authentication", () => { // TODO: make all params const variables it("Header API Key", () => { let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); - let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); + let auth = new petstore.ApiKeyAuthentication("apiKey"); auth.applySecurityAuthentication(ctx); - - expect(ctx.getUrl()).to.equal("http://google.com"); - expect(ctx.getHeaders()).to.have.property("paramName"); - expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); - expect(ctx.getBody()).to.equal(undefined); - }); - it("Query API Key", () => { - let ctx = new petstore.RequestContext("http://google.com?a=b", petstore.HttpMethod.GET); - let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "query", "apiKey",); - auth.applySecurityAuthentication(ctx); - - expect(ctx.getUrl()).to.contain("paramName=apiKey"); - expect(ctx.getHeaders()).to.deep.equal({}); - expect(ctx.getBody()).to.equal(undefined); - }); - - it("Cookie API Key", () => { - let ctx = new petstore.RequestContext("http://google.com", petstore.HttpMethod.GET); - let auth = new petstore.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey",); - auth.applySecurityAuthentication(ctx); - expect(ctx.getUrl()).to.equal("http://google.com"); - expect(ctx.getHeaders()).to.have.property("Cookie"); - expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); + expect(ctx.getHeaders()).to.have.property("api_key"); + expect(ctx.getHeaders()["api_key"]).to.equal("apiKey"); expect(ctx.getBody()).to.equal(undefined); - }); + }); }) }); \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/.gitignore b/samples/openapi3/client/petstore/typescript/tests/inversify/.gitignore new file mode 100644 index 000000000000..1521c8b7652b --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/inversify/package-lock.json new file mode 100644 index 000000000000..4a4443268a07 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/package-lock.json @@ -0,0 +1,1490 @@ +{ + "name": "typescript-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/chai": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", + "dev": true + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=", + "dev": true + }, + "@types/mocha": { + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", + "dev": true + }, + "@types/node": { + "version": "8.10.61", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.61.tgz", + "integrity": "sha512-l+zSbvT8TPRaCxL1l9cwHCb0tSqGAGcjPJFItGGYat5oCTiq1uQQKYg5m7AF1mgnEBzFXGLJ2LRmNjtreRX76Q==", + "dev": true + }, + "@types/rewire": { + "version": "2.5.28", + "resolved": "https://registry.npmjs.org/@types/rewire/-/rewire-2.5.28.tgz", + "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" + }, + "acorn": { + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" + } + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" + }, + "ansi-escapes": { + "version": "3.1.0", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "requires": { + "callsites": "^0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "http://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==" + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "requires": { + "esutils": "^2.0.2" + } + }, + "emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true + }, + "enhanced-resolve": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", + "integrity": "sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.5.0", + "tapable": "^1.0.0" + } + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "dev": true, + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "eslint": { + "version": "4.19.1", + "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "requires": { + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", + "table": "4.0.2", + "text-table": "~0.2.0" + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" + }, + "espree": { + "version": "3.5.4", + "resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "external-editor": { + "version": "2.2.0", + "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "requires": { + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", + "write": "^0.2.1" + } + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", + "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, + "inversify": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/inversify/-/inversify-5.0.1.tgz", + "integrity": "sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ==" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "loader-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", + "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "memory-fs": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", + "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", + "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==" + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "reflect-metadata": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" + }, + "regexpp": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==" + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=" + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "rewire": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/rewire/-/rewire-4.0.1.tgz", + "integrity": "sha512-+7RQ/BYwTieHVXetpKhT11UbfF6v1kGhKFrtZN7UDL2PybMsSt/rpLWeEUGF5Ndsl1D5BxiCB14VDJyoX+noYw==", + "requires": { + "eslint": "^4.19.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "requires": { + "is-promise": "^2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=" + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "requires": { + "rx-lite": "*" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + } + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "requires": { + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + }, + "tapable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "ts-loader": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-7.0.5.tgz", + "integrity": "sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig==", + "dev": true, + "requires": { + "chalk": "^2.3.0", + "enhanced-resolve": "^4.0.0", + "loader-utils": "^1.0.2", + "micromatch": "^4.0.0", + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "ts-node": { + "version": "8.10.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz", + "integrity": "sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==", + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" + } + } + }, + "ts-petstore-client": { + "version": "file:../../builds/inversify", + "requires": { + "@types/node": "*", + "@types/node-fetch": "^2.5.7", + "btoa": "^1.2.1", + "es6-promise": "^4.2.4", + "form-data": "^2.5.0", + "inversify": "^5.0.1", + "node-fetch": "^2.6.0", + "url-parse": "^1.4.3" + }, + "dependencies": { + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" + }, + "@types/node": { + "version": "12.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" + }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "es6-promise": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==" + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "inversify": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/inversify/-/inversify-5.0.1.tgz", + "integrity": "sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ==" + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "whatwg-fetch": ">=0.10.0" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "querystringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", + "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==" + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" + }, + "url-parse": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", + "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", + "requires": { + "querystringify": "^2.0.0", + "requires-port": "^1.0.0" + } + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + } + } + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "typescript": { + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", + "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "requires": { + "mkdirp": "^0.5.1" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + } + } +} diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/package.json b/samples/openapi3/client/petstore/typescript/tests/inversify/package.json new file mode 100644 index 000000000000..544fe42fe745 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/package.json @@ -0,0 +1,34 @@ +{ + "private": true, + "dependencies": { + "@types/rewire": "^2.5.28", + "form-data": "^2.5.0", + "inversify": "^5.0.1", + "reflect-metadata": "^0.1.13", + "rewire": "^4.0.1", + "ts-node": "^8.10.2", + "ts-petstore-client": "file:../../builds/inversify" + }, + "scripts": { + "test": "mocha test/**/*.test.ts test/*.test.ts -r ts-node/register --timeout 10000", + "build": "tsc" + }, + "devDependencies": { + "@types/chai": "^4.0.1", + "@types/isomorphic-fetch": "0.0.34", + "@types/mocha": "^2.2.41", + "@types/node": "^8.10.38", + "chai": "^4.1.0", + "mocha": "^5.2.0", + "ts-loader": "^7.0.5", + "typescript": "^3.9.5" + }, + "name": "typescript-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/pom.xml b/samples/openapi3/client/petstore/typescript/tests/inversify/pom.xml new file mode 100644 index 000000000000..7ee6deb8c6af --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + org.openapitools + TypeScriptInversifyPetstoreClientTests + pom + 1.0-SNAPSHOT + TS Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-build + pre-integration-test + + exec + + + npm + + run + build + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/test/services.test.ts b/samples/openapi3/client/petstore/typescript/tests/inversify/test/services.test.ts new file mode 100644 index 000000000000..264dbad31af8 --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/test/services.test.ts @@ -0,0 +1,139 @@ +import "reflect-metadata"; +import { Container } from "inversify"; + +import * as petstore from "ts-petstore-client"; +import * as petstoreInternals from "ts-petstore-client/dist/apis/PetApi"; + +import { expect, assert } from "chai"; +import * as fs from "fs"; + +describe("ApiServiceBinder", () => { + let container: Container, apiServiceBinder: petstore.ApiServiceBinder; + beforeEach("create new container and api service binder", () => { + container = new Container(); + apiServiceBinder = new petstore.ApiServiceBinder(container); + }); + + it("falls back to defaults", () => { + const petApi = container.resolve(petstore.PetApi); + expect(petApi).to.be.an.instanceof(petstore.PetApi); + }); + + it("binds server config", async () => { + const url = "foobar"; + let callCount = 0; + const mockServer = { + makeRequestContext(endpoint: string, httpMethod: petstore.HttpMethod): petstore.RequestContext { + callCount++; + return new petstore.RequestContext(url, httpMethod); + } + }; + apiServiceBinder.bindServerConfiguration.toConstantValue(mockServer); + + const requestFactory = container.resolve(petstoreInternals.PetApiRequestFactory); + const request = await requestFactory.deletePet(42); + + expect(callCount).to.equal(1); + expect(request.getUrl()).to.equal(url); + }); + + it("binds predefined server config", () => { + apiServiceBinder.bindServerConfigurationToPredefined(0); + const server = container.get(petstore.AbstractServerConfiguration); + + expect(server).to.equal(petstore.server1); + }); + + it("binds server config to url", async () => { + const url = "foobar"; + const petId = 42; + apiServiceBinder.bindServerConfigurationToURL(url); + + const requestFactory = container.resolve(petstoreInternals.PetApiRequestFactory); + const request = await requestFactory.deletePet(petId); + + expect(request.getUrl()).to.equal(`${url}/pet/${petId}`); + }); + + it("binds http library", async () => { + const requests: Array = []; + const mockHttpLibrary = { + async send(request: petstore.RequestContext): Promise { + requests.push(request); + return new petstore.ResponseContext(200, {}, { + async text() { return ""; }, + async binary() { return Buffer.from(""); } + }); + } + }; + apiServiceBinder.bindHttpLibrary.toConstantValue(mockHttpLibrary); + + const petApi = container.resolve(petstore.PetApi); + await petApi.deletePet(42); + + expect(requests).to.be.of.length(1); + expect(requests[0].getUrl()).to.include("/pet/42"); + }); + + it("binds middleware", async () => { + let preCallCount = 0, postCallCount = 0; + const mockMiddleware = { + async pre(context: petstore.RequestContext): Promise { + preCallCount++; + return context; + }, + async post(context: petstore.ResponseContext): Promise { + postCallCount++; + return context; + } + }; + apiServiceBinder.bindMiddleware.toConstantValue(mockMiddleware); + + const petApi = container.resolve(petstore.PetApi); + await petApi.addPet({ name: "Foo Bear", photoUrls: [] }); + + expect(preCallCount).to.equal(1); + expect(postCallCount).to.equal(1); + }); + + it("binds auth method", async () => { + const header = "x-custom-header"; + const value = "foobar"; + let callCount = 0; + const mockAuthMethod = { + getName(): string { + return "api_key"; + }, + applySecurityAuthentication(context: petstore.RequestContext) { + callCount++; + context.setHeaderParam(header, value); + } + }; + apiServiceBinder.bindAuthMethod.toConstantValue(mockAuthMethod); + + const requestFactory = container.resolve(petstoreInternals.PetApiRequestFactory); + const request = await requestFactory.getPetById(42); + + expect(callCount).to.equal(1); + expect(request.getHeaders()[header]).to.equal(value); + }); + + it("binds predefined auth method", async () => { + const authName = "api_key"; + const value = "foobar"; + container.bind(petstore.AuthApiKey).toConstantValue(value).whenTargetNamed(authName); + apiServiceBinder.bindAuthMethodToPredefined(authName); + + const requestFactory = container.resolve(petstoreInternals.PetApiRequestFactory); + const request = await requestFactory.getPetById(42); + + expect(request.getHeaders()["api_key"]).to.equal(value); + }); + + it("binds all api services", () => { + apiServiceBinder.bindAllApiServices(); + const petApi = container.get(petstore.AbstractPetApi); + + expect(petApi).to.be.an.instanceof(petstore.PetApi); + }); +}) \ No newline at end of file diff --git a/samples/openapi3/client/petstore/typescript/tests/inversify/tsconfig.json b/samples/openapi3/client/petstore/typescript/tests/inversify/tsconfig.json new file mode 100644 index 000000000000..4596f6e40bcf --- /dev/null +++ b/samples/openapi3/client/petstore/typescript/tests/inversify/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha", + "node" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} diff --git a/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json index d85b9b69d6c7..331d8ab1d563 100644 --- a/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/package-lock.json @@ -540,6 +540,15 @@ "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", "optional": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -1778,6 +1787,12 @@ "object-assign": "^4.0.1" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "optional": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -2799,6 +2814,12 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, + "nan": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -2886,7 +2907,8 @@ "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "optional": true }, "npm-run-path": { "version": "2.0.2", @@ -3144,7 +3166,8 @@ "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "optional": true }, "pify": { "version": "4.0.1", @@ -4297,25 +4320,29 @@ "dependencies": { "@types/form-data": { "version": "2.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", "requires": { "@types/node": "*" } }, "@types/jquery": { "version": "3.3.29", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", + "integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==", "requires": { "@types/sizzle": "*" } }, "@types/node": { "version": "12.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" }, "@types/rx": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*", @@ -4333,18 +4360,21 @@ }, "@types/rx-core": { "version": "4.0.3", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" }, "@types/rx-core-binding": { "version": "4.0.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", "requires": { "@types/rx-core": "*" } }, "@types/rx-lite": { "version": "4.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz", + "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==", "requires": { "@types/rx-core": "*", "@types/rx-core-binding": "*" @@ -4352,97 +4382,113 @@ }, "@types/rx-lite-aggregates": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-async": { "version": "4.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-backpressure": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-coincidence": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-experimental": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-joinpatterns": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-testing": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", "requires": { "@types/rx-lite-virtualtime": "*" } }, "@types/rx-lite-time": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", "requires": { "@types/rx-lite": "*" } }, "@types/rx-lite-virtualtime": { "version": "4.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", "requires": { "@types/rx-lite": "*" } }, "@types/sizzle": { "version": "2.3.2", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", + "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" }, "asynckit": { "version": "0.4.0", - "bundled": true + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "btoa": { "version": "1.2.1", - "bundled": true + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { "version": "1.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "es6-promise": { "version": "4.2.6", - "bundled": true + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, "form-data": { "version": "2.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -4451,45 +4497,54 @@ }, "jquery": { "version": "3.5.1", - "bundled": true + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "mime-db": { "version": "1.40.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { "mime-db": "1.40.0" } }, "querystringify": { "version": "2.1.1", - "bundled": true + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" }, "requires-port": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "rxjs": { "version": "6.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", "requires": { "tslib": "^1.9.0" } }, "tslib": { "version": "1.9.3", - "bundled": true + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, "typescript": { "version": "2.9.2", - "bundled": true + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" }, "url-parse": { "version": "1.4.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -4786,7 +4841,11 @@ "version": "1.2.13", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts index 5ef07e31ed4c..3bb4a6e8b337 100644 --- a/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/jquery/test/api/PetApi.test.ts @@ -5,7 +5,7 @@ import * as petstore from 'ts-petstore-client'; // @ts-ignore import petImage from "./pet.png"; -const configuration = new petstore.Configuration() +const configuration = petstore.createConfiguration() const petApi = new petstore.PetApi(configuration) const tag = new petstore.Tag(); diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json b/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json index a66a373e5ed5..e944217a93a9 100644 --- a/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/package-lock.json @@ -1234,11 +1234,13 @@ "dependencies": { "@types/node": { "version": "14.0.6", - "bundled": true + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.6.tgz", + "integrity": "sha512-FbNmu4F67d3oZMWBV6Y4MaPER+0EpE9eIYf2yaHhCWovc1dlXCZkqGX4NLHfVVr6umt20TNBdRzrNJIzIKfdbw==" }, "@types/node-fetch": { "version": "2.5.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", "requires": { "@types/node": "*", "form-data": "^3.0.0" @@ -1258,30 +1260,36 @@ }, "asynckit": { "version": "0.4.0", - "bundled": true + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "btoa": { "version": "1.2.1", - "bundled": true + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" }, "combined-stream": { "version": "1.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, "delayed-stream": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "es6-promise": { "version": "4.2.8", - "bundled": true + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "form-data": { "version": "2.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -1290,34 +1298,41 @@ }, "mime-db": { "version": "1.44.0", - "bundled": true + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" }, "mime-types": { "version": "2.1.27", - "bundled": true, + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", "requires": { "mime-db": "1.44.0" } }, "node-fetch": { "version": "2.6.0", - "bundled": true + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.1", - "bundled": true + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" }, "requires-port": { "version": "1.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "typescript": { "version": "3.9.3", - "bundled": true + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==" }, "url-parse": { "version": "1.4.7", - "bundled": true, + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -1325,7 +1340,8 @@ }, "whatwg-fetch": { "version": "3.0.0", - "bundled": true + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } }, diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/package.json b/samples/openapi3/client/petstore/typescript/tests/object_params/package.json index cef97214aee2..c9f65b041ef5 100644 --- a/samples/openapi3/client/petstore/typescript/tests/object_params/package.json +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/package.json @@ -8,7 +8,6 @@ "ts-petstore-client": "file:../../builds/object_params" }, "scripts": { - "prepublish": "npm install ../../builds/object_params && npm run build", "test": "mocha test/**/*.ts -r ts-node/register --timeout 10000", "build": "tsc" }, diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml b/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml index edc01a0776bf..fd904b1ce3b8 100644 --- a/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/pom.xml @@ -39,6 +39,20 @@ + + npm-build + pre-integration-test + + exec + + + npm + + run + build + + + npm-test integration-test diff --git a/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts b/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts index d795f643c7ba..578fab4b0863 100644 --- a/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts +++ b/samples/openapi3/client/petstore/typescript/tests/object_params/test/api/PetApi.test.ts @@ -3,9 +3,10 @@ import * as petstore from 'ts-petstore-client' import { expect, assert } from "chai"; import * as fs from 'fs'; -const configuration = new petstore.Configuration() +const configuration = petstore.createConfiguration() const petApi = new petstore.PetApi(configuration) + const tag = new petstore.Tag(); tag.name = "tag1" tag.id = Math.floor(Math.random() * 100000) From efb9722757d9c94dca63157d2ed96478643d45bb Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 14 Jun 2020 19:44:04 +0200 Subject: [PATCH 85/85] Restore changes to CONTRIBUTING.md from PR #6489 --- CONTRIBUTING.md | 3 ++- docs/contributing.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fae0a9edfe2a..e701fb5ba33a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,7 +85,8 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell scripts under `bin` folder. For example, run `./bin/generate-samples.sh ./bin/configs/python*` to update the Python PetStore samples under [`samples/`](https://github.com/openapitools/openapi-generator/tree/master/samples/). For Windows users, please install [Git BASH](https://gitforwindows.org/) in order to run the scripts. +- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. - Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) diff --git a/docs/contributing.md b/docs/contributing.md index 32d2e408ba12..f7182f3a21f1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -89,7 +89,8 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell scripts under `bin` folder. For example, run `./bin/generate-samples.sh ./bin/configs/python*` to update the Python PetStore samples under [`samples/`](https://github.com/openapitools/openapi-generator/tree/master/samples/). For Windows users, please install [Git BASH](https://gitforwindows.org/) in order to run the scripts. +- Update the Petstore sample by running the shell scripts under `bin` and `bin/openapi3` folder. For example, run `./bin/python-petstore.sh` and `./bin/openapi3/python-petstore.sh` to update the Python PetStore API client under [`samples/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/python) and [`samples/openapi3/client/petstore/python`](https://github.com/openapitools/openapi-generator/tree/master/samples/openapi3/client/petstore/python). For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python`. - Run the tests in the sample folder using maven `mvn integration-test -rf :`, e.g. open a shell in `samples/client/petstore/python`, run `mvn integration-test -rf :PythonPetstoreClientTests`. The artifactId of the project can be found in the pom.xml file. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases)