diff --git a/bin/typescript-axios-petstore-all.sh b/bin/typescript-axios-petstore-all.sh index 064014269a2..de66b03904f 100755 --- a/bin/typescript-axios-petstore-all.sh +++ b/bin/typescript-axios-petstore-all.sh @@ -2,5 +2,6 @@ ./bin/typescript-axios-petstore-target-es6.sh ./bin/typescript-axios-petstore-with-npm-version.sh +./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh ./bin/typescript-axios-petstore-interfaces.sh ./bin/typescript-axios-petstore.sh diff --git a/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.json b/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.json new file mode 100755 index 00000000000..e2db69bfb2d --- /dev/null +++ b/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.json @@ -0,0 +1,9 @@ +{ + "npmName": "@swagger/typescript-axios-petstore", + "npmVersion": "1.0.0", + "npmRepository": "https://skimdb.npmjs.com/registry", + "snapshot": false, + "withSeparateModelsAndApi": true, + "modelPackage": "model.some.levels.deep", + "apiPackage": "api.another.level" +} diff --git a/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh b/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh new file mode 100755 index 00000000000..8ef8b455dae --- /dev/null +++ b/bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.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-axios -c bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.json -o samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 41d911813f2..fdf070f433c 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -31,6 +31,7 @@ declare -a scripts=("./bin/openapi3/ruby-client-petstore.sh" "./bin/php-ze-ph-petstore-server.sh" "./bin/openapi3/php-petstore.sh" "./bin/typescript-angular-petstore-all.sh" +"./bin/typescript-axios-petstore-all.sh" "./bin/typescript-fetch-petstore-all.sh" "./bin/typescript-node-petstore-all.sh" "./bin/typescript-inversify-petstore.sh" diff --git a/bin/windows/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat b/bin/windows/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat new file mode 100644 index 00000000000..d67cc90b5bc --- /dev/null +++ b/bin/windows/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat @@ -0,0 +1,12 @@ +@ECHO OFF + +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\2_0\petstore.yaml -g typescript-axios -c bin\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.json -o samples\client\petstore\typescript-axios\builds\with-npm-version-and-separate-models-and-api + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index 29ff5edec1a..e4ac3d1570b 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -18,3 +18,4 @@ sidebar_label: typescript-axios |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| |snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| +|withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java index 0bb64748d78..13f7edcbd8b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java @@ -20,6 +20,7 @@ package org.openapitools.codegen.languages; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.parser.util.SchemaTypeUtil; +import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; @@ -36,11 +37,14 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege public static final String NPM_REPOSITORY = "npmRepository"; public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; + public static final String SEPARATE_MODELS_AND_API = "withSeparateModelsAndApi"; protected String npmName = null; protected String npmVersion = "1.0.0"; protected String npmRepository = null; + private String tsModelPackage = ""; + public TypeScriptAxiosClientCodegen() { super(); @@ -56,6 +60,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); + this.cliOptions.add(new CliOption(SEPARATE_MODELS_AND_API, "Put the model and api in separate folders and in separate classes", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @Override @@ -92,19 +97,57 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege this.npmRepository = npmRepository; } + private static String getRelativeToRoot(String path) { + StringBuilder sb = new StringBuilder(); + int slashCount = path.split("/").length; + if (slashCount == 0) { + sb.append("./"); + } else { + for (int i = 0; i < slashCount; ++i) { + sb.append("../"); + } + } + return sb.toString(); + } + @Override public void processOpts() { super.processOpts(); + tsModelPackage = modelPackage.replaceAll("\\.", "/"); + String tsApiPackage = apiPackage.replaceAll("\\.", "/"); + + String modelRelativeToRoot = getRelativeToRoot(tsModelPackage); + String apiRelativeToRoot = getRelativeToRoot(tsApiPackage); + + additionalProperties.put("tsModelPackage", tsModelPackage); + additionalProperties.put("tsApiPackage", tsApiPackage); + additionalProperties.put("apiRelativeToRoot", apiRelativeToRoot); + additionalProperties.put("modelRelativeToRoot", modelRelativeToRoot); + supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts")); + supportingFiles.add(new SupportingFile("baseApi.mustache", "", "base.ts")); supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("custom.d.mustache", "", "custom.d.ts")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); + boolean separateModelsAndApi = (boolean)additionalProperties.getOrDefault(SEPARATE_MODELS_AND_API, false); + + if (separateModelsAndApi) { + modelTemplateFiles.put("model.mustache", ".ts"); + apiTemplateFiles.put("apiInner.mustache", ".ts"); + supportingFiles.add(new SupportingFile("modelIndex.mustache", tsModelPackage, "index.ts")); + } + if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } + + boolean emptyModelOrApi = separateModelsAndApi && StringUtils.isAnyBlank(modelPackage, apiPackage); + if (emptyModelOrApi) { + throw new RuntimeException("apiPackage and modelPackage must be defined"); + } } @Override @@ -128,8 +171,8 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { objs = super.postProcessOperationsWithModels(objs, allModels); - Map vals = (Map) objs.get("operations"); - List operations = (List) vals.get("operation"); + Map vals = (Map) objs.getOrDefault("operations", new HashMap<>()); + List operations = (List) vals.getOrDefault("operation", new ArrayList<>()); /* Filter all the operations that are multipart/form-data operations and set the vendor extension flag 'multipartFormData' for the template to work with. @@ -147,6 +190,37 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege addImport(codegenModel, codegenModel.additionalPropertiesType); } + @Override + @SuppressWarnings("unchecked") + public Map postProcessModels(Map objs) { + Map ret = super.postProcessModels(objs); + // Deduce the model file name in kebab case + List> models = (List>) ret.get("models"); + for (Map m : models) { + CodegenModel model = (CodegenModel) m.get("model"); + model.classFilename = model.classname.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT); + } + // Apply the model file name to the imports as well + for (Map m : (List>) ret.get("imports")) { + String javaImport = m.get("import").substring(modelPackage.length() + 1); + String tsImport = tsModelPackage + "/" + javaImport; + m.put("tsImport", tsImport); + m.put("class", javaImport); + m.put("filename", javaImport.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT)); + } + return ret; + } + + @Override + public String toModelFilename(String name) { + return super.toModelFilename(name).replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT); + } + + @Override + public String toApiFilename(String name) { + return super.toApiFilename(name).replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT); + } + private void addNpmPackageGeneration() { if (additionalProperties.containsKey(NPM_NAME)) { this.setNpmName(additionalProperties.get(NPM_NAME).toString()); diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache index acda64ef8c2..2d6ac670cc0 100644 --- a/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache @@ -2,352 +2,19 @@ /// {{>licenseInfo}} -import * as url from "url"; -import { Configuration } from "./configuration"; +{{^withSeparateModelsAndApi}} +import * as url from 'url'; +import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; - -const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; {{#models}} {{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}} {{/models}} -{{#apiInfo}}{{#apis}}{{#operations}} -/** - * {{classname}} - axios parameter creator{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): RequestArgs { - {{#allParams}} - {{#required}} - // verify required parameter '{{paramName}}' is not null or undefined - if ({{paramName}} === null || {{paramName}} === undefined) { - throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); - } - {{/required}} - {{/allParams}} - const localVarPath = `{{{path}}}`{{#pathParams}} - .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} - const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}FormData(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} - - {{#authMethods}} - // authentication {{name}} required - {{#isApiKey}} - {{#isKeyInHeader}} - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; - localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue; - } - {{/isKeyInHeader}} - {{#isKeyInQuery}} - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; - localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue; - } - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if (configuration && (configuration.username || configuration.password)) { - localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password); - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } - {{/isOAuth}} - - {{/authMethods}} - {{#queryParams}} - {{#isListContainer}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); - {{/isCollectionFormatMulti}} - } - {{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined) { - {{#isDateTime}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); - {{/isDateTime}} - {{^isDateTime}} - {{#isDate}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); - {{/isDate}} - {{^isDate}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/isDate}} - {{/isDateTime}} - } - {{/isListContainer}} - - {{/queryParams}} - {{#headerParams}} - {{#isListContainer}} - if ({{paramName}}) { - localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); - } - {{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined && {{paramName}} !== null) { - localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); - } - {{/isListContainer}} - - {{/headerParams}} - {{#vendorExtensions}} - {{#formParams}} - {{#isListContainer}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - localVarFormParams.append('{{baseName}}', element as any); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}}{{^multipartFormData}} - localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}}{{#multipartFormData}} - localVarFormParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}} - {{/isCollectionFormatMulti}} - }{{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined) { {{^multipartFormData}} - localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}} - localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/multipartFormData}} - } - {{/isListContainer}} - {{/formParams}}{{/vendorExtensions}} - {{#hasFormParams}}{{#multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} - {{/hasFormParams}} - {{#bodyParam}} - {{^consumes}} - localVarHeaderParameter['Content-Type'] = 'application/json'; - {{/consumes}} - {{#consumes.0}} - localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; - {{/consumes.0}} - - {{/bodyParam}} - localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; - {{#hasFormParams}} - localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; - {{/hasFormParams}} - {{#bodyParam}} - const needsSerialization = ("{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || ""); - {{/bodyParam}} - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - {{/operation}} - } -}; - -/** - * {{classname}} - functional programming interface{{#description}} - * {{{description}}}{{/description}} - * @export - */ -export const {{classname}}Fp = function(configuration?: Configuration) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { - const localVarAxiosArgs = {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); - }; - }, - {{/operation}} - } -}; - -/** - * {{classname}} - factory interface{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { - return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(axios, basePath); - }, - {{/operation}} - }; -}; - -{{#withInterfaces}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export interface {{classname}}Interface { -{{#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 - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>; - -{{/operation}} -} - -{{/withInterfaces}} -/** - * {{classname}} - object-oriented interface{{#description}} - * {{{description}}}{{/description}} - * @export - * @class {{classname}} - * @extends {BaseAPI} - */ -{{#withInterfaces}} -export class {{classname}} extends BaseAPI implements {{classname}}Interface { -{{/withInterfaces}} -{{^withInterfaces}} -export class {{classname}} extends BaseAPI { -{{/withInterfaces}} - {{#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}} - */ - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.axios, this.basePath); - } - - {{/operation}} -} +{{#apiInfo}}{{#apis}} +{{>apiInner}} +{{/apis}}{{/apiInfo}} +{{/withSeparateModelsAndApi}}{{#withSeparateModelsAndApi}} +{{#apiInfo}}{{#apis}}{{#operations}}export * from './{{apiPackage}}/{{classFilename}}'; {{/operations}}{{/apis}}{{/apiInfo}} +{{/withSeparateModelsAndApi}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache new file mode 100644 index 00000000000..e505bbff9af --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache @@ -0,0 +1,305 @@ +{{#withSeparateModelsAndApi}} +// tslint:disable +/// +{{>licenseInfo}} + +import * as url from 'url'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +import { Configuration } from '{{apiRelativeToRoot}}configuration'; +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '{{apiRelativeToRoot}}base'; + +{{#imports}}import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}'; +{{/imports}} +{{/withSeparateModelsAndApi}} +{{^withSeparateModelsAndApi}} +{{/withSeparateModelsAndApi}} +{{#operations}} +/** + * {{classname}} - axios parameter creator{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) { + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): RequestArgs { + {{#allParams}} + {{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + {{/required}} + {{/allParams}} + const localVarPath = `{{{path}}}`{{#pathParams}} + .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} + const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}FormData(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} + + {{#authMethods}} + // authentication {{name}} required + {{#isApiKey}} + {{#isKeyInHeader}} + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? configuration.apiKey("{{keyParamName}}") + : configuration.apiKey; + localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue; + } + {{/isKeyInHeader}} + {{#isKeyInQuery}} + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? configuration.apiKey("{{keyParamName}}") + : configuration.apiKey; + localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue; + } + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isBasic}} + // http basic authentication required + if (configuration && (configuration.username || configuration.password)) { + localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password); + } + {{/isBasic}} + {{#isOAuth}} + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + {{/isOAuth}} + + {{/authMethods}} + {{#queryParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined) { + {{#isDateTime}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); + {{/isDate}} + {{^isDate}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + {{/isListContainer}} + + {{/queryParams}} + {{#headerParams}} + {{#isListContainer}} + if ({{paramName}}) { + localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined && {{paramName}} !== null) { + localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); + } + {{/isListContainer}} + + {{/headerParams}} + {{#vendorExtensions}} + {{#formParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + localVarFormParams.append('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}}{{^multipartFormData}} + localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}} + {{/isCollectionFormatMulti}} + }{{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined) { {{^multipartFormData}} + localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/multipartFormData}} + } + {{/isListContainer}} + {{/formParams}}{{/vendorExtensions}} + {{#hasFormParams}}{{#multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} + {{/hasFormParams}} + {{#bodyParam}} + {{^consumes}} + localVarHeaderParameter['Content-Type'] = 'application/json'; + {{/consumes}} + {{#consumes.0}} + localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; + {{/consumes.0}} + + {{/bodyParam}} + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + {{#hasFormParams}} + localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; + {{/hasFormParams}} + {{#bodyParam}} + const needsSerialization = ("{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || ""); + {{/bodyParam}} + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + {{/operation}} + } +}; + +/** + * {{classname}} - functional programming interface{{#description}} + * {{{description}}}{{/description}} + * @export + */ +export const {{classname}}Fp = function(configuration?: Configuration) { + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { + const localVarAxiosArgs = {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + {{/operation}} + } +}; + +/** + * {{classname}} - factory interface{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { + return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(axios, basePath); + }, + {{/operation}} + }; +}; + +{{#withInterfaces}} +/** + * {{classname}} - interface{{#description}} + * {{&description}}{{/description}} + * @export + * @interface {{classname}} + */ +export interface {{classname}}Interface { +{{#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 + */ + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>; + +{{/operation}} +} + +{{/withInterfaces}} +/** + * {{classname}} - object-oriented interface{{#description}} + * {{{description}}}{{/description}} + * @export + * @class {{classname}} + * @extends {BaseAPI} + */ +{{#withInterfaces}} +export class {{classname}} extends BaseAPI implements {{classname}}Interface { +{{/withInterfaces}} +{{^withInterfaces}} +export class {{classname}} extends BaseAPI { +{{/withInterfaces}} + {{#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}} + */ + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { + return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.axios, this.basePath); + } + + {{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/baseApi.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/baseApi.mustache new file mode 100644 index 00000000000..acd6198b335 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-axios/baseApi.mustache @@ -0,0 +1,58 @@ +// tslint:disable +/// +{{>licenseInfo}} + +import { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/model.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/model.mustache new file mode 100644 index 00000000000..8806847340b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-axios/model.mustache @@ -0,0 +1,9 @@ +// tslint:disable +/// +{{>licenseInfo}} +{{#withSeparateModelsAndApi}}{{#imports}} +import { {{class}} } from './{{filename}}';{{/imports}}{{/withSeparateModelsAndApi}} +{{#models}}{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}} +{{/model}}{{/models}} + diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/modelIndex.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/modelIndex.mustache new file mode 100644 index 00000000000..947111206c5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-axios/modelIndex.mustache @@ -0,0 +1,2 @@ +{{#models}}{{#model}}export * from './{{classFilename}}';{{/model}} +{{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/default/api.ts b/samples/client/petstore/typescript-axios/builds/default/api.ts index 84881cfbf4e..f2fca10eb5d 100644 --- a/samples/client/petstore/typescript-axios/builds/default/api.ts +++ b/samples/client/petstore/typescript-axios/builds/default/api.ts @@ -13,61 +13,10 @@ */ -import * as url from "url"; -import { Configuration } from "./configuration"; +import * as url from 'url'; +import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; - -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * Describes the result of uploading an image resource @@ -321,14 +270,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); + addPet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -357,7 +306,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -549,14 +498,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); + updatePet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -585,7 +534,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -716,15 +665,15 @@ export const PetApiFp = function(configuration?: Configuration) { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(pet, options); + addPet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -739,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).deletePet(petId, apiKey, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -753,7 +702,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByStatus(status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -767,7 +716,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByTags(tags, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -781,21 +730,21 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).getPetById(petId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(pet, options); + updatePet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -811,7 +760,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -827,7 +776,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -842,12 +791,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(axios, basePath); + addPet(body: Pet, options?: any) { + return PetApiFp(configuration).addPet(body, options)(axios, basePath); }, /** * @@ -893,12 +842,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(axios, basePath); + updatePet(body: Pet, options?: any) { + return PetApiFp(configuration).updatePet(body, options)(axios, basePath); }, /** * @@ -937,13 +886,13 @@ export class PetApi extends BaseAPI { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.axios, this.basePath); + public addPet(body: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(body, options)(this.axios, this.basePath); } /** @@ -998,13 +947,13 @@ export class PetApi extends BaseAPI { /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.axios, this.basePath); + public updatePet(body: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(body, options)(this.axios, this.basePath); } /** @@ -1037,6 +986,7 @@ export class PetApi extends BaseAPI { } + /** * StoreApi - axios parameter creator * @export @@ -1150,14 +1100,14 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options: any = {}): RequestArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); + placeOrder(body: Order, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); } const localVarPath = `/store/order`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1177,7 +1127,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(order || {}) : (order || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1204,7 +1154,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).deleteOrder(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1217,7 +1167,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getInventory(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1231,21 +1181,21 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getOrderById(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(order, options); + placeOrder(body: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1289,12 +1239,12 @@ export const StoreApiFactory = function (configuration?: Configuration, basePath /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(axios, basePath); + placeOrder(body: Order, options?: any) { + return StoreApiFp(configuration).placeOrder(body, options)(axios, basePath); }, }; }; @@ -1344,17 +1294,18 @@ export class StoreApi extends BaseAPI { /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StoreApi */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.axios, this.basePath); + public placeOrder(body: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(body, options)(this.axios, this.basePath); } } + /** * UserApi - axios parameter creator * @export @@ -1364,14 +1315,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); + createUser(body: User, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); } const localVarPath = `/user`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1391,7 +1342,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1401,14 +1352,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + createUsersWithArrayInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } const localVarPath = `/user/createWithArray`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1428,7 +1379,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1438,14 +1389,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); + createUsersWithListInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); } const localVarPath = `/user/createWithList`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1465,7 +1416,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1618,18 +1569,18 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options: any = {}): RequestArgs { + updateUser(username: string, body: User, options: any = {}): RequestArgs { // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('username','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('user','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('body','Required parameter body was null or undefined when calling updateUser.'); } const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); @@ -1650,7 +1601,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1669,43 +1620,43 @@ export const UserApiFp = function(configuration?: Configuration) { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(user, options); + createUser(body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(user, options); + createUsersWithArrayInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(user, options); + createUsersWithListInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1719,7 +1670,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).deleteUser(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1733,7 +1684,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).getUserByName(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1748,7 +1699,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).loginUser(username, password, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1761,22 +1712,22 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).logoutUser(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, user, options); + updateUser(username: string, body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1791,32 +1742,32 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(axios, basePath); + createUser(body: User, options?: any) { + return UserApiFp(configuration).createUser(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(axios, basePath); + createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithArrayInput(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(axios, basePath); + createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithListInput(body, options)(axios, basePath); }, /** * This can only be done by the logged in user. @@ -1862,12 +1813,12 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(axios, basePath); + updateUser(username: string, body: User, options?: any) { + return UserApiFp(configuration).updateUser(username, body, options)(axios, basePath); }, }; }; @@ -1882,37 +1833,37 @@ export class UserApi extends BaseAPI { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.axios, this.basePath); + public createUser(body: User, options?: any) { + return UserApiFp(this.configuration).createUser(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.axios, this.basePath); + public createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.axios, this.basePath); + public createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(body, options)(this.axios, this.basePath); } /** @@ -1967,14 +1918,15 @@ export class UserApi extends BaseAPI { * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.axios, this.basePath); + public updateUser(username: string, body: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, body, options)(this.axios, this.basePath); } } + diff --git a/samples/client/petstore/typescript-axios/builds/default/base.ts b/samples/client/petstore/typescript-axios/builds/default/base.ts new file mode 100644 index 00000000000..6d211454b13 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/default/base.ts @@ -0,0 +1,69 @@ +// tslint:disable +/// +/** + * 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 { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/builds/es6-target/api.ts b/samples/client/petstore/typescript-axios/builds/es6-target/api.ts index 84881cfbf4e..f2fca10eb5d 100644 --- a/samples/client/petstore/typescript-axios/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-axios/builds/es6-target/api.ts @@ -13,61 +13,10 @@ */ -import * as url from "url"; -import { Configuration } from "./configuration"; +import * as url from 'url'; +import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; - -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * Describes the result of uploading an image resource @@ -321,14 +270,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); + addPet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -357,7 +306,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -549,14 +498,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); + updatePet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -585,7 +534,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -716,15 +665,15 @@ export const PetApiFp = function(configuration?: Configuration) { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(pet, options); + addPet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -739,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).deletePet(petId, apiKey, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -753,7 +702,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByStatus(status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -767,7 +716,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByTags(tags, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -781,21 +730,21 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).getPetById(petId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(pet, options); + updatePet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -811,7 +760,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -827,7 +776,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -842,12 +791,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(axios, basePath); + addPet(body: Pet, options?: any) { + return PetApiFp(configuration).addPet(body, options)(axios, basePath); }, /** * @@ -893,12 +842,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(axios, basePath); + updatePet(body: Pet, options?: any) { + return PetApiFp(configuration).updatePet(body, options)(axios, basePath); }, /** * @@ -937,13 +886,13 @@ export class PetApi extends BaseAPI { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.axios, this.basePath); + public addPet(body: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(body, options)(this.axios, this.basePath); } /** @@ -998,13 +947,13 @@ export class PetApi extends BaseAPI { /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.axios, this.basePath); + public updatePet(body: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(body, options)(this.axios, this.basePath); } /** @@ -1037,6 +986,7 @@ export class PetApi extends BaseAPI { } + /** * StoreApi - axios parameter creator * @export @@ -1150,14 +1100,14 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options: any = {}): RequestArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); + placeOrder(body: Order, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); } const localVarPath = `/store/order`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1177,7 +1127,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(order || {}) : (order || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1204,7 +1154,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).deleteOrder(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1217,7 +1167,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getInventory(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1231,21 +1181,21 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getOrderById(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(order, options); + placeOrder(body: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1289,12 +1239,12 @@ export const StoreApiFactory = function (configuration?: Configuration, basePath /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(axios, basePath); + placeOrder(body: Order, options?: any) { + return StoreApiFp(configuration).placeOrder(body, options)(axios, basePath); }, }; }; @@ -1344,17 +1294,18 @@ export class StoreApi extends BaseAPI { /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StoreApi */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.axios, this.basePath); + public placeOrder(body: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(body, options)(this.axios, this.basePath); } } + /** * UserApi - axios parameter creator * @export @@ -1364,14 +1315,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); + createUser(body: User, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); } const localVarPath = `/user`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1391,7 +1342,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1401,14 +1352,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + createUsersWithArrayInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } const localVarPath = `/user/createWithArray`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1428,7 +1379,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1438,14 +1389,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); + createUsersWithListInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); } const localVarPath = `/user/createWithList`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1465,7 +1416,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1618,18 +1569,18 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options: any = {}): RequestArgs { + updateUser(username: string, body: User, options: any = {}): RequestArgs { // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('username','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('user','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('body','Required parameter body was null or undefined when calling updateUser.'); } const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); @@ -1650,7 +1601,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1669,43 +1620,43 @@ export const UserApiFp = function(configuration?: Configuration) { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(user, options); + createUser(body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(user, options); + createUsersWithArrayInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(user, options); + createUsersWithListInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1719,7 +1670,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).deleteUser(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1733,7 +1684,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).getUserByName(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1748,7 +1699,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).loginUser(username, password, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1761,22 +1712,22 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).logoutUser(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, user, options); + updateUser(username: string, body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1791,32 +1742,32 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(axios, basePath); + createUser(body: User, options?: any) { + return UserApiFp(configuration).createUser(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(axios, basePath); + createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithArrayInput(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(axios, basePath); + createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithListInput(body, options)(axios, basePath); }, /** * This can only be done by the logged in user. @@ -1862,12 +1813,12 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(axios, basePath); + updateUser(username: string, body: User, options?: any) { + return UserApiFp(configuration).updateUser(username, body, options)(axios, basePath); }, }; }; @@ -1882,37 +1833,37 @@ export class UserApi extends BaseAPI { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.axios, this.basePath); + public createUser(body: User, options?: any) { + return UserApiFp(this.configuration).createUser(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.axios, this.basePath); + public createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.axios, this.basePath); + public createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(body, options)(this.axios, this.basePath); } /** @@ -1967,14 +1918,15 @@ export class UserApi extends BaseAPI { * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.axios, this.basePath); + public updateUser(username: string, body: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, body, options)(this.axios, this.basePath); } } + diff --git a/samples/client/petstore/typescript-axios/builds/es6-target/base.ts b/samples/client/petstore/typescript-axios/builds/es6-target/base.ts new file mode 100644 index 00000000000..6d211454b13 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/es6-target/base.ts @@ -0,0 +1,69 @@ +// tslint:disable +/// +/** + * 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 { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/builds/with-interfaces/api.ts b/samples/client/petstore/typescript-axios/builds/with-interfaces/api.ts index 0c34eb72902..6105cc8ccb6 100644 --- a/samples/client/petstore/typescript-axios/builds/with-interfaces/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-interfaces/api.ts @@ -13,61 +13,10 @@ */ -import * as url from "url"; -import { Configuration } from "./configuration"; +import * as url from 'url'; +import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; - -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * Describes the result of uploading an image resource @@ -321,14 +270,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); + addPet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -357,7 +306,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -549,14 +498,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); + updatePet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -585,7 +534,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -716,15 +665,15 @@ export const PetApiFp = function(configuration?: Configuration) { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(pet, options); + addPet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -739,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).deletePet(petId, apiKey, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -753,7 +702,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByStatus(status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -767,7 +716,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByTags(tags, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -781,21 +730,21 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).getPetById(petId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(pet, options); + updatePet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -811,7 +760,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -827,7 +776,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -842,12 +791,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(axios, basePath); + addPet(body: Pet, options?: any) { + return PetApiFp(configuration).addPet(body, options)(axios, basePath); }, /** * @@ -893,12 +842,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(axios, basePath); + updatePet(body: Pet, options?: any) { + return PetApiFp(configuration).updatePet(body, options)(axios, basePath); }, /** * @@ -936,12 +885,12 @@ 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 {Pet} body 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): AxiosPromise<{}>; + addPet(body: Pet, options?: any): AxiosPromise<{}>; /** * @@ -987,12 +936,12 @@ export interface PetApiInterface { /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body 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): AxiosPromise<{}>; + updatePet(body: Pet, options?: any): AxiosPromise<{}>; /** * @@ -1030,13 +979,13 @@ export class PetApi extends BaseAPI implements PetApiInterface { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.axios, this.basePath); + public addPet(body: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(body, options)(this.axios, this.basePath); } /** @@ -1091,13 +1040,13 @@ export class PetApi extends BaseAPI implements PetApiInterface { /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.axios, this.basePath); + public updatePet(body: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(body, options)(this.axios, this.basePath); } /** @@ -1130,6 +1079,7 @@ export class PetApi extends BaseAPI implements PetApiInterface { } + /** * StoreApi - axios parameter creator * @export @@ -1243,14 +1193,14 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options: any = {}): RequestArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); + placeOrder(body: Order, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); } const localVarPath = `/store/order`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1270,7 +1220,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(order || {}) : (order || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1297,7 +1247,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).deleteOrder(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1310,7 +1260,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getInventory(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1324,21 +1274,21 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getOrderById(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(order, options); + placeOrder(body: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1382,12 +1332,12 @@ export const StoreApiFactory = function (configuration?: Configuration, basePath /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(axios, basePath); + placeOrder(body: Order, options?: any) { + return StoreApiFp(configuration).placeOrder(body, options)(axios, basePath); }, }; }; @@ -1430,12 +1380,12 @@ export interface StoreApiInterface { /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StoreApiInterface */ - placeOrder(order: Order, options?: any): AxiosPromise; + placeOrder(body: Order, options?: any): AxiosPromise; } @@ -1484,17 +1434,18 @@ export class StoreApi extends BaseAPI implements StoreApiInterface { /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StoreApi */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.axios, this.basePath); + public placeOrder(body: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(body, options)(this.axios, this.basePath); } } + /** * UserApi - axios parameter creator * @export @@ -1504,14 +1455,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); + createUser(body: User, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); } const localVarPath = `/user`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1531,7 +1482,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1541,14 +1492,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + createUsersWithArrayInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } const localVarPath = `/user/createWithArray`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1568,7 +1519,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1578,14 +1529,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); + createUsersWithListInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); } const localVarPath = `/user/createWithList`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1605,7 +1556,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1758,18 +1709,18 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options: any = {}): RequestArgs { + updateUser(username: string, body: User, options: any = {}): RequestArgs { // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('username','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('user','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('body','Required parameter body was null or undefined when calling updateUser.'); } const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); @@ -1790,7 +1741,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1809,43 +1760,43 @@ export const UserApiFp = function(configuration?: Configuration) { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(user, options); + createUser(body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(user, options); + createUsersWithArrayInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(user, options); + createUsersWithListInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1859,7 +1810,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).deleteUser(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1873,7 +1824,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).getUserByName(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1888,7 +1839,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).loginUser(username, password, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1901,22 +1852,22 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).logoutUser(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, user, options); + updateUser(username: string, body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1931,32 +1882,32 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(axios, basePath); + createUser(body: User, options?: any) { + return UserApiFp(configuration).createUser(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(axios, basePath); + createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithArrayInput(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(axios, basePath); + createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithListInput(body, options)(axios, basePath); }, /** * This can only be done by the logged in user. @@ -2002,12 +1953,12 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(axios, basePath); + updateUser(username: string, body: User, options?: any) { + return UserApiFp(configuration).updateUser(username, body, options)(axios, basePath); }, }; }; @@ -2021,32 +1972,32 @@ export interface UserApiInterface { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApiInterface */ - createUser(user: User, options?: any): AxiosPromise<{}>; + createUser(body: User, options?: any): AxiosPromise<{}>; /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApiInterface */ - createUsersWithArrayInput(user: Array, options?: any): AxiosPromise<{}>; + createUsersWithArrayInput(body: Array, options?: any): AxiosPromise<{}>; /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApiInterface */ - createUsersWithListInput(user: Array, options?: any): AxiosPromise<{}>; + createUsersWithListInput(body: Array, options?: any): AxiosPromise<{}>; /** * This can only be done by the logged in user. @@ -2092,12 +2043,12 @@ export interface UserApiInterface { * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApiInterface */ - updateUser(username: string, user: User, options?: any): AxiosPromise<{}>; + updateUser(username: string, body: User, options?: any): AxiosPromise<{}>; } @@ -2111,37 +2062,37 @@ export class UserApi extends BaseAPI implements UserApiInterface { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.axios, this.basePath); + public createUser(body: User, options?: any) { + return UserApiFp(this.configuration).createUser(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.axios, this.basePath); + public createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.axios, this.basePath); + public createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(body, options)(this.axios, this.basePath); } /** @@ -2196,14 +2147,15 @@ export class UserApi extends BaseAPI implements UserApiInterface { * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.axios, this.basePath); + public updateUser(username: string, body: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, body, options)(this.axios, this.basePath); } } + diff --git a/samples/client/petstore/typescript-axios/builds/with-interfaces/base.ts b/samples/client/petstore/typescript-axios/builds/with-interfaces/base.ts new file mode 100644 index 00000000000..6d211454b13 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-interfaces/base.ts @@ -0,0 +1,69 @@ +// tslint:disable +/// +/** + * 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 { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/builds/with-npm-version-and-separate-models-and-api/.gitignore b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.gitignore new file mode 100644 index 00000000000..35e2fb2b02e --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.gitignore @@ -0,0 +1,3 @@ +wwwroot/*.js +node_modules +typings diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.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-axios/builds/with-npm-version-and-separate-models-and-api/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.openapi-generator/VERSION new file mode 100644 index 00000000000..afa63656064 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/README.md b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/README.md new file mode 100644 index 00000000000..4672431c735 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/README.md @@ -0,0 +1,45 @@ +## @swagger/typescript-axios-petstore@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments: + +Environment +* Node.js +* Webpack +* Browserify + +Language level +* ES5 - you must have a Promises/A+ library installed +* ES6 + +Module system +* CommonJS +* ES6 module system + +It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) + +### 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 @swagger/typescript-axios-petstore@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api.ts new file mode 100644 index 00000000000..6ffb004f180 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api.ts @@ -0,0 +1,20 @@ +// tslint:disable +/// +/** + * 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. + */ + + + +export * from './api.another.level/pet-api'; +export * from './api.another.level/store-api'; +export * from './api.another.level/user-api'; + diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/pet-api.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/pet-api.ts new file mode 100644 index 00000000000..76c6558696a --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/pet-api.ts @@ -0,0 +1,746 @@ +// tslint:disable +/// +/** + * 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 * as url from 'url'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +import { Configuration } from '../../../configuration'; +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../../../base'; + +import { ApiResponse } from '../../../model/some/levels/deep'; +import { Pet } from '../../../model/some/levels/deep'; +/** + * PetApi - axios parameter creator + * @export + */ +export const PetApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addPet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); + } + const localVarPath = `/pet`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deletePet(petId: number, apiKey?: string, options: any = {}): RequestArgs { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); + } + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + if (apiKey !== undefined && apiKey !== null) { + localVarHeaderParameter['api_key'] = String(apiKey); + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * 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} + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): RequestArgs { + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); + } + const localVarPath = `/pet/findByStatus`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + if (status) { + localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS.csv); + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * 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} + */ + findPetsByTags(tags: Array, options: any = {}): RequestArgs { + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); + } + const localVarPath = `/pet/findByTags`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + if (tags) { + localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS.csv); + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * 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} + */ + getPetById(petId: number, options: any = {}): RequestArgs { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); + } + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api_key required + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? configuration.apiKey("api_key") + : configuration.apiKey; + localVarHeaderParameter["api_key"] = localVarApiKeyValue; + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Update an existing pet + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); + } + const localVarPath = `/pet`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @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} + */ + updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): RequestArgs { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new URLSearchParams(); + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @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} + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): RequestArgs { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); + } + const localVarPath = `/pet/{petId}/uploadImage` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new FormData(); + + // authentication petstore_auth required + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) + : configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + + + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * PetApi - functional programming interface + * @export + */ +export const PetApiFp = function(configuration?: Configuration) { + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addPet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deletePet(petId: number, apiKey?: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).deletePet(petId, apiKey, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * 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} + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByStatus(status, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * 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} + */ + findPetsByTags(tags: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByTags(tags, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * 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} + */ + getPetById(petId: number, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).getPetById(petId, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Update an existing pet + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @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} + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePetWithForm(petId, name, status, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @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} + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + } +}; + +/** + * PetApi - factory interface + * @export + */ +export const PetApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addPet(body: Pet, options?: any) { + return PetApiFp(configuration).addPet(body, options)(axios, basePath); + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deletePet(petId: number, apiKey?: string, options?: any) { + return PetApiFp(configuration).deletePet(petId, apiKey, options)(axios, basePath); + }, + /** + * 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} + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { + return PetApiFp(configuration).findPetsByStatus(status, options)(axios, basePath); + }, + /** + * 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} + */ + findPetsByTags(tags: Array, options?: any) { + return PetApiFp(configuration).findPetsByTags(tags, options)(axios, basePath); + }, + /** + * 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} + */ + getPetById(petId: number, options?: any) { + return PetApiFp(configuration).getPetById(petId, options)(axios, basePath); + }, + /** + * + * @summary Update an existing pet + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePet(body: Pet, options?: any) { + return PetApiFp(configuration).updatePet(body, options)(axios, basePath); + }, + /** + * + * @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} + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { + return PetApiFp(configuration).updatePetWithForm(petId, name, status, options)(axios, basePath); + }, + /** + * + * @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} + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { + return PetApiFp(configuration).uploadFile(petId, additionalMetadata, file, options)(axios, basePath); + }, + }; +}; + +/** + * PetApi - object-oriented interface + * @export + * @class PetApi + * @extends {BaseAPI} + */ +export class PetApi extends BaseAPI { + /** + * + * @summary Add a new pet to the store + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public addPet(body: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(body, options)(this.axios, this.basePath); + } + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public deletePet(petId: number, apiKey?: string, options?: any) { + return PetApiFp(this.configuration).deletePet(petId, apiKey, options)(this.axios, this.basePath); + } + + /** + * 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 PetApi + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { + return PetApiFp(this.configuration).findPetsByStatus(status, options)(this.axios, this.basePath); + } + + /** + * 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 PetApi + */ + public findPetsByTags(tags: Array, options?: any) { + return PetApiFp(this.configuration).findPetsByTags(tags, options)(this.axios, this.basePath); + } + + /** + * 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 PetApi + */ + public getPetById(petId: number, options?: any) { + return PetApiFp(this.configuration).getPetById(petId, options)(this.axios, this.basePath); + } + + /** + * + * @summary Update an existing pet + * @param {Pet} body Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public updatePet(body: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(body, options)(this.axios, this.basePath); + } + + /** + * + * @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 PetApi + */ + public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { + return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options)(this.axios, this.basePath); + } + + /** + * + * @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 PetApi + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { + return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options)(this.axios, this.basePath); + } + +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/store-api.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/store-api.ts new file mode 100644 index 00000000000..6a825faa9e5 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/store-api.ts @@ -0,0 +1,338 @@ +// tslint:disable +/// +/** + * 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 * as url from 'url'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +import { Configuration } from '../../../configuration'; +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../../../base'; + +import { Order } from '../../../model/some/levels/deep'; +/** + * StoreApi - axios parameter creator + * @export + */ +export const StoreApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * 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} + */ + deleteOrder(orderId: string, options: any = {}): RequestArgs { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); + } + const localVarPath = `/store/order/{orderId}` + .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options: any = {}): RequestArgs { + const localVarPath = `/store/inventory`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api_key required + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? configuration.apiKey("api_key") + : configuration.apiKey; + localVarHeaderParameter["api_key"] = localVarApiKeyValue; + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * 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} + */ + getOrderById(orderId: number, options: any = {}): RequestArgs { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); + } + const localVarPath = `/store/order/{orderId}` + .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Place an order for a pet + * @param {Order} body order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + placeOrder(body: Order, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); + } + const localVarPath = `/store/order`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * StoreApi - functional programming interface + * @export + */ +export const StoreApiFp = function(configuration?: Configuration) { + return { + /** + * 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} + */ + deleteOrder(orderId: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).deleteOrder(orderId, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: number; }> { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getInventory(options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * 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} + */ + getOrderById(orderId: number, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getOrderById(orderId, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Place an order for a pet + * @param {Order} body order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + placeOrder(body: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + } +}; + +/** + * StoreApi - factory interface + * @export + */ +export const StoreApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + return { + /** + * 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} + */ + deleteOrder(orderId: string, options?: any) { + return StoreApiFp(configuration).deleteOrder(orderId, options)(axios, basePath); + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options?: any) { + return StoreApiFp(configuration).getInventory(options)(axios, basePath); + }, + /** + * 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} + */ + getOrderById(orderId: number, options?: any) { + return StoreApiFp(configuration).getOrderById(orderId, options)(axios, basePath); + }, + /** + * + * @summary Place an order for a pet + * @param {Order} body order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + placeOrder(body: Order, options?: any) { + return StoreApiFp(configuration).placeOrder(body, options)(axios, basePath); + }, + }; +}; + +/** + * StoreApi - object-oriented interface + * @export + * @class StoreApi + * @extends {BaseAPI} + */ +export class StoreApi extends BaseAPI { + /** + * 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 StoreApi + */ + public deleteOrder(orderId: string, options?: any) { + return StoreApiFp(this.configuration).deleteOrder(orderId, options)(this.axios, this.basePath); + } + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public getInventory(options?: any) { + return StoreApiFp(this.configuration).getInventory(options)(this.axios, this.basePath); + } + + /** + * 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 StoreApi + */ + public getOrderById(orderId: number, options?: any) { + return StoreApiFp(this.configuration).getOrderById(orderId, options)(this.axios, this.basePath); + } + + /** + * + * @summary Place an order for a pet + * @param {Order} body order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public placeOrder(body: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(body, options)(this.axios, this.basePath); + } + +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/user-api.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/user-api.ts new file mode 100644 index 00000000000..05bc3cd4d45 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/api/another/level/user-api.ts @@ -0,0 +1,643 @@ +// tslint:disable +/// +/** + * 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 * as url from 'url'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +import { Configuration } from '../../../configuration'; +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../../../base'; + +import { User } from '../../../model/some/levels/deep'; +/** + * UserApi - axios parameter creator + * @export + */ +export const UserApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} body Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUser(body: User, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); + } + const localVarPath = `/user`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } + const localVarPath = `/user/createWithArray`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); + } + const localVarPath = `/user/createWithList`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * 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} + */ + deleteUser(username: string, options: any = {}): RequestArgs { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); + } + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @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} + */ + getUserByName(username: string, options: any = {}): RequestArgs { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); + } + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @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} + */ + loginUser(username: string, password: string, options: any = {}): RequestArgs { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); + } + const localVarPath = `/user/login`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (username !== undefined) { + localVarQueryParameter['username'] = username; + } + + if (password !== undefined) { + localVarQueryParameter['password'] = password; + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser(options: any = {}): RequestArgs { + const localVarPath = `/user/logout`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} body Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUser(username: string, body: User, options: any = {}): RequestArgs { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('username','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('body','Required parameter body was null or undefined when calling updateUser.'); + } + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * UserApi - functional programming interface + * @export + */ +export const UserApiFp = function(configuration?: Configuration) { + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} body Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUser(body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * 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} + */ + deleteUser(username: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).deleteUser(username, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @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} + */ + getUserByName(username: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).getUserByName(username, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @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} + */ + loginUser(username: string, password: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).loginUser(username, password, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser(options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).logoutUser(options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} body Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUser(username: string, body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, body, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + } +}; + +/** + * UserApi - factory interface + * @export + */ +export const UserApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} body Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUser(body: User, options?: any) { + return UserApiFp(configuration).createUser(body, options)(axios, basePath); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithArrayInput(body, options)(axios, basePath); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithListInput(body, options)(axios, basePath); + }, + /** + * 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} + */ + deleteUser(username: string, options?: any) { + return UserApiFp(configuration).deleteUser(username, options)(axios, basePath); + }, + /** + * + * @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} + */ + getUserByName(username: string, options?: any) { + return UserApiFp(configuration).getUserByName(username, options)(axios, basePath); + }, + /** + * + * @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} + */ + loginUser(username: string, password: string, options?: any) { + return UserApiFp(configuration).loginUser(username, password, options)(axios, basePath); + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser(options?: any) { + return UserApiFp(configuration).logoutUser(options)(axios, basePath); + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} body Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUser(username: string, body: User, options?: any) { + return UserApiFp(configuration).updateUser(username, body, options)(axios, basePath); + }, + }; +}; + +/** + * UserApi - object-oriented interface + * @export + * @class UserApi + * @extends {BaseAPI} + */ +export class UserApi extends BaseAPI { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} body Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUser(body: User, options?: any) { + return UserApiFp(this.configuration).createUser(body, options)(this.axios, this.basePath); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(body, options)(this.axios, this.basePath); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(body, options)(this.axios, this.basePath); + } + + /** + * 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 UserApi + */ + public deleteUser(username: string, options?: any) { + return UserApiFp(this.configuration).deleteUser(username, options)(this.axios, this.basePath); + } + + /** + * + * @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 UserApi + */ + public getUserByName(username: string, options?: any) { + return UserApiFp(this.configuration).getUserByName(username, options)(this.axios, this.basePath); + } + + /** + * + * @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 UserApi + */ + public loginUser(username: string, password: string, options?: any) { + return UserApiFp(this.configuration).loginUser(username, password, options)(this.axios, this.basePath); + } + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public logoutUser(options?: any) { + return UserApiFp(this.configuration).logoutUser(options)(this.axios, this.basePath); + } + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} body Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public updateUser(username: string, body: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, body, options)(this.axios, this.basePath); + } + +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/base.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/base.ts new file mode 100644 index 00000000000..6d211454b13 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/base.ts @@ -0,0 +1,69 @@ +// tslint:disable +/// +/** + * 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 { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/builds/with-npm-version-and-separate-models-and-api/configuration.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/configuration.ts new file mode 100644 index 00000000000..5fafdac5b93 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/configuration.ts @@ -0,0 +1,74 @@ +// tslint:disable +/** + * 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. + */ + + +export interface ConfigurationParameters { + apiKey?: string | ((name: string) => string); + username?: string; + password?: string; + accessToken?: string | ((name: string, scopes?: string[]) => string); + basePath?: string; + baseOptions?: any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | ((name: string) => string); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | ((name: string, scopes?: string[]) => string); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/custom.d.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/custom.d.ts new file mode 100644 index 00000000000..32534cb1663 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/custom.d.ts @@ -0,0 +1 @@ +declare module 'url'; \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/git_push.sh b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/git_push.sh new file mode 100644 index 00000000000..188eeaea7bc --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/git_push.sh @@ -0,0 +1,51 @@ +#!/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-axios/builds/with-npm-version-and-separate-models-and-api/index.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/index.ts new file mode 100644 index 00000000000..768b2ffab47 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/index.ts @@ -0,0 +1,16 @@ +// tslint:disable +/** + * 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. + */ + + +export * from "./api"; +export * from "./configuration"; diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/api-response.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/api-response.ts new file mode 100644 index 00000000000..98c1a3e3a43 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/api-response.ts @@ -0,0 +1,44 @@ +// tslint:disable +/// +/** + * 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 + * @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-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/category.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/category.ts new file mode 100644 index 00000000000..18b4fc3adad --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/category.ts @@ -0,0 +1,38 @@ +// tslint:disable +/// +/** + * 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 + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + + + diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/index.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/index.ts new file mode 100644 index 00000000000..b86bffba515 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/index.ts @@ -0,0 +1,6 @@ +export * from './api-response'; +export * from './category'; +export * from './order'; +export * from './pet'; +export * from './tag'; +export * from './user'; diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/order.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/order.ts new file mode 100644 index 00000000000..a0539b0522a --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/order.ts @@ -0,0 +1,78 @@ +// tslint:disable +/// +/** + * 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 + * @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-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/pet.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/pet.ts new file mode 100644 index 00000000000..436bb34e9ec --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/pet.ts @@ -0,0 +1,80 @@ +// tslint:disable +/// +/** + * 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 + * @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-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/tag.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/tag.ts new file mode 100644 index 00000000000..49ee1ed6269 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/tag.ts @@ -0,0 +1,38 @@ +// tslint:disable +/// +/** + * 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 + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + + + diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/user.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/user.ts new file mode 100644 index 00000000000..0483794d533 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/model/some/levels/deep/user.ts @@ -0,0 +1,74 @@ +// tslint:disable +/// +/** + * 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 + * @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-axios/builds/with-npm-version-and-separate-models-and-api/package.json b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json new file mode 100644 index 00000000000..25ffad1bf5a --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json @@ -0,0 +1,32 @@ +{ + "name": "@swagger/typescript-axios-petstore", + "version": "1.0.0", + "description": "OpenAPI client for @swagger/typescript-axios-petstore", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "axios", + "typescript", + "openapi-client", + "openapi-generator", + "@swagger/typescript-axios-petstore" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc --outDir dist/", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "axios": "^0.18.0" + }, + "peerDependencies": { + }, + "devDependencies": { + "@types/node": "^8.0.9", + "typescript": "^2.4" + }, + "publishConfig":{ + "registry":"https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/tsconfig.json b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/tsconfig.json new file mode 100644 index 00000000000..50ab7fa3f2f --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version/api.ts index 84881cfbf4e..f2fca10eb5d 100644 --- a/samples/client/petstore/typescript-axios/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version/api.ts @@ -13,61 +13,10 @@ */ -import * as url from "url"; -import { Configuration } from "./configuration"; +import * as url from 'url'; +import { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; - -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * Describes the result of uploading an image resource @@ -321,14 +270,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); + addPet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -357,7 +306,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -549,14 +498,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options: any = {}): RequestArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); + updatePet(body: Pet, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); } const localVarPath = `/pet`; const localVarUrlObj = url.parse(localVarPath, true); @@ -585,7 +534,7 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -716,15 +665,15 @@ export const PetApiFp = function(configuration?: Configuration) { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(pet, options); + addPet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).addPet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -739,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).deletePet(petId, apiKey, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -753,7 +702,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByStatus(status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -767,7 +716,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).findPetsByTags(tags, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -781,21 +730,21 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).getPetById(petId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(pet, options); + updatePet(body: Pet, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePet(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -811,7 +760,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -827,7 +776,7 @@ export const PetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = PetApiAxiosParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -842,12 +791,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(axios, basePath); + addPet(body: Pet, options?: any) { + return PetApiFp(configuration).addPet(body, options)(axios, basePath); }, /** * @@ -893,12 +842,12 @@ export const PetApiFactory = function (configuration?: Configuration, basePath?: /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(axios, basePath); + updatePet(body: Pet, options?: any) { + return PetApiFp(configuration).updatePet(body, options)(axios, basePath); }, /** * @@ -937,13 +886,13 @@ export class PetApi extends BaseAPI { /** * * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.axios, this.basePath); + public addPet(body: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(body, options)(this.axios, this.basePath); } /** @@ -998,13 +947,13 @@ export class PetApi extends BaseAPI { /** * * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store + * @param {Pet} body Pet object that needs to be added to the store * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PetApi */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.axios, this.basePath); + public updatePet(body: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(body, options)(this.axios, this.basePath); } /** @@ -1037,6 +986,7 @@ export class PetApi extends BaseAPI { } + /** * StoreApi - axios parameter creator * @export @@ -1150,14 +1100,14 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options: any = {}): RequestArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); + placeOrder(body: Order, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); } const localVarPath = `/store/order`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1177,7 +1127,7 @@ export const StoreApiAxiosParamCreator = function (configuration?: Configuration delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(order || {}) : (order || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1204,7 +1154,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).deleteOrder(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1217,7 +1167,7 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getInventory(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1231,21 +1181,21 @@ export const StoreApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).getOrderById(orderId, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(order, options); + placeOrder(body: Order, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = StoreApiAxiosParamCreator(configuration).placeOrder(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1289,12 +1239,12 @@ export const StoreApiFactory = function (configuration?: Configuration, basePath /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(axios, basePath); + placeOrder(body: Order, options?: any) { + return StoreApiFp(configuration).placeOrder(body, options)(axios, basePath); }, }; }; @@ -1344,17 +1294,18 @@ export class StoreApi extends BaseAPI { /** * * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet + * @param {Order} body order placed for purchasing the pet * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StoreApi */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.axios, this.basePath); + public placeOrder(body: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(body, options)(this.axios, this.basePath); } } + /** * UserApi - axios parameter creator * @export @@ -1364,14 +1315,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); + createUser(body: User, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); } const localVarPath = `/user`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1391,7 +1342,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1401,14 +1352,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + createUsersWithArrayInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } const localVarPath = `/user/createWithArray`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1428,7 +1379,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1438,14 +1389,14 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options: any = {}): RequestArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); + createUsersWithListInput(body: Array, options: any = {}): RequestArgs { + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); } const localVarPath = `/user/createWithList`; const localVarUrlObj = url.parse(localVarPath, true); @@ -1465,7 +1416,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1618,18 +1569,18 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options: any = {}): RequestArgs { + updateUser(username: string, body: User, options: any = {}): RequestArgs { // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError('username','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('user','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('body','Required parameter body was null or undefined when calling updateUser.'); } const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); @@ -1650,7 +1601,7 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) delete localVarUrlObj.search; localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(user || {}) : (user || ""); + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body || {}) : (body || ""); return { url: url.format(localVarUrlObj), @@ -1669,43 +1620,43 @@ export const UserApiFp = function(configuration?: Configuration) { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(user, options); + createUser(body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUser(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(user, options); + createUsersWithArrayInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(user, options); + createUsersWithListInput(body: Array, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).createUsersWithListInput(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1719,7 +1670,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).deleteUser(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1733,7 +1684,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).getUserByName(username, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1748,7 +1699,7 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).loginUser(username, password, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** @@ -1761,22 +1712,22 @@ export const UserApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).logoutUser(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, /** * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { - const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, user, options); + updateUser(username: string, body: User, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = UserApiAxiosParamCreator(configuration).updateUser(username, body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; - return axios.request(axiosRequestArgs); + return axios.request(axiosRequestArgs); }; }, } @@ -1791,32 +1742,32 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(axios, basePath); + createUser(body: User, options?: any) { + return UserApiFp(configuration).createUser(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(axios, basePath); + createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithArrayInput(body, options)(axios, basePath); }, /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(axios, basePath); + createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(configuration).createUsersWithListInput(body, options)(axios, basePath); }, /** * This can only be done by the logged in user. @@ -1862,12 +1813,12 @@ export const UserApiFactory = function (configuration?: Configuration, basePath? * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(axios, basePath); + updateUser(username: string, body: User, options?: any) { + return UserApiFp(configuration).updateUser(username, body, options)(axios, basePath); }, }; }; @@ -1882,37 +1833,37 @@ export class UserApi extends BaseAPI { /** * This can only be done by the logged in user. * @summary Create user - * @param {User} user Created user object + * @param {User} body Created user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.axios, this.basePath); + public createUser(body: User, options?: any) { + return UserApiFp(this.configuration).createUser(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.axios, this.basePath); + public createUsersWithArrayInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(body, options)(this.axios, this.basePath); } /** * * @summary Creates list of users with given input array - * @param {Array} user List of user object + * @param {Array} body List of user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.axios, this.basePath); + public createUsersWithListInput(body: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(body, options)(this.axios, this.basePath); } /** @@ -1967,14 +1918,15 @@ export class UserApi extends BaseAPI { * 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 {User} body Updated user object * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.axios, this.basePath); + public updateUser(username: string, body: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, body, options)(this.axios, this.basePath); } } + diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version/base.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version/base.ts new file mode 100644 index 00000000000..6d211454b13 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version/base.ts @@ -0,0 +1,69 @@ +// tslint:disable +/// +/** + * 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 { Configuration } from "./configuration"; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @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-axios/tests/default/dist/PetApi.js b/samples/client/petstore/typescript-axios/tests/default/dist/PetApi.js deleted file mode 100644 index 6952694afb9..00000000000 --- a/samples/client/petstore/typescript-axios/tests/default/dist/PetApi.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var chai_1 = require("chai"); -var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore"); -var axios_1 = require("axios"); -describe("PetApi", function () { - function runSuite(description, requestOptions, customAxiosInstance) { - describe(description, function () { - var api; - var fixture = createTestFixture(); - beforeEach(function () { - api = new typescript_axios_petstore_1.PetApi(undefined, undefined, customAxiosInstance); - }); - it("should add and delete Pet", function () { - return api.addPet(fixture, requestOptions).then(function () { }); - }); - it("should get Pet by ID", function () { - return api - .getPetById(fixture.id, requestOptions) - .then(function (result) { - return chai_1.expect(result.data).to.deep.equal(fixture); - }); - }); - it("should update Pet by ID", function () { - return api - .getPetById(fixture.id, requestOptions) - .then(function (response) { - var result = response.data; - result.name = "newname"; - return api.updatePet(result, requestOptions).then(function () { - return api - .getPetById(fixture.id, requestOptions) - .then(function (response) { - return chai_1.expect(response.data.name).to.deep.equal("newname"); - }); - }); - }); - }); - it("should delete Pet", function () { - return api.deletePet(fixture.id, requestOptions); - }); - it("should not contain deleted Pet", function () { - return api.getPetById(fixture.id, requestOptions).then(function (result) { - return chai_1.expect(result.data).to.not.exist; - }, function (err) { - return chai_1.expect(err).to.exist; - }); - }); - }); - } - runSuite("without custom request options"); - runSuite("with custom request options", { - credentials: "include", - mode: "cors" - }); - runSuite("without custom axios instance"); - runSuite("with custom axios instance", {}, axios_1.default); - runSuite("with custom request options and custom axios instance", { - credentials: "include", - mode: "cors" - }, axios_1.default); -}); -function createTestFixture(ts) { - if (ts === void 0) { ts = Date.now(); } - var category = { - id: ts, - name: "category" + ts - }; - var pet = { - id: ts, - name: "pet" + ts, - category: category, - photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"], - status: typescript_axios_petstore_1.Pet.StatusEnum.Available, - tags: [] - }; - return pet; -} diff --git a/samples/client/petstore/typescript-axios/tests/default/dist/PetApiFactory.js b/samples/client/petstore/typescript-axios/tests/default/dist/PetApiFactory.js deleted file mode 100644 index 8b2f7183299..00000000000 --- a/samples/client/petstore/typescript-axios/tests/default/dist/PetApiFactory.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var chai_1 = require("chai"); -var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore"); -var typescript_axios_petstore_2 = require("@swagger/typescript-axios-petstore"); -var axios_1 = require("axios"); -var config; -before(function () { - config = new typescript_axios_petstore_2.Configuration(); - config.accessToken = "foobar"; - config.apiKey = function (securityName) { - // for multiple apiKey security - if (securityName === "api_key") { - return "foobar"; - } - return; - }; - config.username = "foo"; - config.password = "bar"; -}); -describe("PetApiFactory", function () { - function runSuite(description, requestOptions, customAxiosInstance) { - describe(description, function () { - var fixture = createTestFixture(); - it("should add and delete Pet", function () { - return typescript_axios_petstore_1.PetApiFactory(config, undefined, customAxiosInstance) - .addPet(fixture, requestOptions) - .then(function () { }); - }); - it("should get Pet by ID", function () { - return typescript_axios_petstore_1.PetApiFactory(config, undefined, customAxiosInstance) - .getPetById(fixture.id, requestOptions) - .then(function (result) { - return chai_1.expect(result.data).to.deep.equal(fixture); - }); - }); - it("should update Pet by ID", function () { - return typescript_axios_petstore_1.PetApiFactory(config, undefined, customAxiosInstance) - .getPetById(fixture.id, requestOptions) - .then(function (result) { - result.data.name = "newname"; - return typescript_axios_petstore_1.PetApiFactory(config) - .updatePet(result.data, requestOptions) - .then(function () { - return typescript_axios_petstore_1.PetApiFactory(config) - .getPetById(fixture.id, requestOptions) - .then(function (result) { - return chai_1.expect(result.data.name).to.deep.equal("newname"); - }); - }); - }); - }); - it("should delete Pet", function () { - return typescript_axios_petstore_1.PetApiFactory(config, undefined, customAxiosInstance).deletePet(fixture.id, requestOptions); - }); - it("should not contain deleted Pet", function () { - return typescript_axios_petstore_1.PetApiFactory(config, undefined, customAxiosInstance) - .getPetById(fixture.id, requestOptions) - .then(function (result) { - return chai_1.expect(result.data).to.not.exist; - }, function (err) { - return chai_1.expect(err).to.exist; - }); - }); - }); - } - runSuite("without custom request options"); - runSuite("with custom request options", { - credentials: "include", - mode: "cors" - }); - runSuite("without custom axios instance"); - runSuite("with custom axios instance", {}, axios_1.default); - runSuite("with custom request options and custom axios instance", { - credentials: "include", - mode: "cors" - }, axios_1.default); -}); -function createTestFixture(ts) { - if (ts === void 0) { ts = Date.now(); } - var category = { - id: ts, - name: "category" + ts - }; - var pet = { - id: ts, - name: "pet" + ts, - category: category, - photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"], - status: typescript_axios_petstore_1.Pet.StatusEnum.Available, - tags: [] - }; - return pet; -} diff --git a/samples/client/petstore/typescript-axios/tests/default/dist/StoreApi.js b/samples/client/petstore/typescript-axios/tests/default/dist/StoreApi.js deleted file mode 100644 index 943b5108e24..00000000000 --- a/samples/client/petstore/typescript-axios/tests/default/dist/StoreApi.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var chai_1 = require("chai"); -var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore"); -var axios_1 = require("axios"); -describe("StoreApi", function () { - function runSuite(description, requestOptions, customAxiosInstance) { - describe(description, function () { - var api; - beforeEach(function () { - api = new typescript_axios_petstore_1.StoreApi(undefined, undefined, customAxiosInstance); - }); - it("should get inventory", function () { - return api - .getInventory(requestOptions) - .then(function (result) { - chai_1.expect(Object.keys(result)).to.not.be.empty; - }); - }); - }); - } - runSuite("without custom request options"); - runSuite("with custom request options", { - credentials: "include", - mode: "cors" - }); - runSuite("without custom axios instance"); - runSuite("with custom axios instance", {}, axios_1.default); - runSuite("with custom request options and custom axios instance", { - credentials: "include", - mode: "cors" - }, axios_1.default); -}); diff --git a/samples/client/petstore/typescript-axios/tests/default/dist/StoreApiFactory.js b/samples/client/petstore/typescript-axios/tests/default/dist/StoreApiFactory.js deleted file mode 100644 index 76e5b5bd428..00000000000 --- a/samples/client/petstore/typescript-axios/tests/default/dist/StoreApiFactory.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var chai_1 = require("chai"); -var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore"); -var typescript_axios_petstore_2 = require("@swagger/typescript-axios-petstore"); -var axios_1 = require("axios"); -var config; -before(function () { - config = new typescript_axios_petstore_2.Configuration(); - config.accessToken = "foobar"; - config.apiKey = function (securityName) { - // for multiple apiKey security - if (securityName === "api_key") { - return "foobar"; - } - return; - }; - config.username = "foo"; - config.password = "bar"; -}); -describe("StoreApiFactory", function () { - function runSuite(description, requestOptions, customAxiosInstance) { - describe(description, function () { - it("should get inventory", function () { - return typescript_axios_petstore_1.StoreApiFactory(config, undefined, customAxiosInstance) - .getInventory(requestOptions) - .then(function (result) { - chai_1.expect(Object.keys(result.data)).to.not.be.empty; - }); - }); - }); - } - runSuite("without custom request options"); - runSuite("with custom request options", { - credentials: "include", - mode: "cors" - }); - runSuite("without custom axios instance"); - runSuite("with custom axios instance", {}, axios_1.default); - runSuite("with custom request options and custom axios instance", { - credentials: "include", - mode: "cors" - }, axios_1.default); -}); diff --git a/samples/client/petstore/typescript-axios/tests/default/dist/index.js b/samples/client/petstore/typescript-axios/tests/default/dist/index.js deleted file mode 100644 index 0b29af76274..00000000000 --- a/samples/client/petstore/typescript-axios/tests/default/dist/index.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("./PetApi"); -require("./StoreApi"); -require("./PetApiFactory"); -require("./StoreApiFactory");