diff --git a/bin/typescript-axios-petstore-all.sh b/bin/typescript-axios-petstore-all.sh index 58d13d10f62caf213e373f585a81394ed00a67a7..b9b65dbfece1c37ad66483c1051e94bbcc4a3c85 100755 --- a/bin/typescript-axios-petstore-all.sh +++ b/bin/typescript-axios-petstore-all.sh @@ -5,4 +5,5 @@ ./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh ./bin/typescript-axios-petstore-with-complex-headers.sh ./bin/typescript-axios-petstore-interfaces.sh +./bin/typescript-axios-petstore-use-single-request-parameter.sh ./bin/typescript-axios-petstore.sh diff --git a/bin/typescript-axios-petstore-use-single-request-parameter.json b/bin/typescript-axios-petstore-use-single-request-parameter.json new file mode 100755 index 0000000000000000000000000000000000000000..48075d554f5a4ea1a2129ada829bea589d5bd6e7 --- /dev/null +++ b/bin/typescript-axios-petstore-use-single-request-parameter.json @@ -0,0 +1,7 @@ +{ + "npmName": "@openapitools/typescript-axios-petstore", + "npmVersion": "1.0.0", + "npmRepository": "https://skimdb.npmjs.com/registry", + "snapshot": false, + "useSingleRequestParameter":true +} diff --git a/bin/typescript-axios-petstore-use-single-request-parameter.sh b/bin/typescript-axios-petstore-use-single-request-parameter.sh new file mode 100755 index 0000000000000000000000000000000000000000..314d997393f61ca55d434f4ecc7bf706088403e0 --- /dev/null +++ b/bin/typescript-axios-petstore-use-single-request-parameter.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} -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-use-single-request-parameter.json -o samples/client/petstore/typescript-axios/builds/use-single-request-parameter $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index b990ed95bd453bd247d3080eadcdbb6321a9faa2..2b223e662346995baa0f5d697b256b28bad09417 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -20,6 +20,7 @@ sidebar_label: typescript-axios |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| +|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |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| |withoutPrefixEnums|Don't prefix enum names with class names| |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 1b6e80926395949ecebcb417224b94cd44276fa6..b1f44e6ff51249e09033a2f66887ba8dab906acb 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 @@ -36,10 +36,12 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege public static final String WITH_INTERFACES = "withInterfaces"; public static final String SEPARATE_MODELS_AND_API = "withSeparateModelsAndApi"; public static final String WITHOUT_PREFIX_ENUMS = "withoutPrefixEnums"; + public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter"; protected String npmRepository = null; private String tsModelPackage = ""; + private boolean useSingleRequestParameter = false; public TypeScriptAxiosClientCodegen() { super(); @@ -57,6 +59,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege 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())); this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); + this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString())); } @Override @@ -124,6 +127,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege } } + if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) { + this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER)); + } + writePropertyBack(USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter()); + if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } @@ -205,7 +213,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege } } } - + // Apply the model file name to the imports as well for (Map<String, String> m : (List<Map<String, String>>) objs.get("imports")) { String javaImport = m.get("import").substring(modelPackage.length() + 1); @@ -248,4 +256,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); } + private boolean getUseSingleRequestParameter() { + return useSingleRequestParameter; + } + + private void setUseSingleRequestParameter(boolean useSingleRequestParameter) { + this.useSingleRequestParameter = useSingleRequestParameter; + } } diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache index 5beec794912a6dfa02cc41e834cfd7e575225936..cde65e0edd4db171ad4ee5917d2f4f35867f4177 100644 --- a/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache @@ -35,17 +35,34 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur * @param {*} [options] Override http request option. * @throws {RequiredError} */ + {{^useSingleRequestParameter}} {{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): Promise<RequestArgs> => { + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + {{nickname}}: async ({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}options: any = {}): Promise<RequestArgs> => { + {{/useSingleRequestParameter}} {{#allParams}} {{#required}} // verify required parameter '{{paramName}}' is not null or undefined + {{^useSingleRequestParameter}} if ({{paramName}} === null || {{paramName}} === undefined) { throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); } + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { + throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + {{/useSingleRequestParameter}} {{/required}} {{/allParams}} + {{^useSingleRequestParameter}} const localVarPath = `{{{path}}}`{{#pathParams}} .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + const localVarPath = `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}; + {{/useSingleRequestParameter}} const localVarUrlObj = globalImportUrl.parse(localVarPath, true); let baseOptions; if (configuration) { @@ -104,6 +121,7 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur {{/authMethods}} {{#queryParams}} {{#isListContainer}} + {{^useSingleRequestParameter}} if ({{paramName}}) { {{#isCollectionFormatMulti}} localVarQueryParameter['{{baseName}}'] = {{paramName}}; @@ -112,8 +130,20 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); {{/isCollectionFormatMulti}} } + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + if (requestParameters.{{paramName}}) { + {{#isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = requestParameters.{{paramName}}; + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = requestParameters.{{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/isCollectionFormatMulti}} + } + {{/useSingleRequestParameter}} {{/isListContainer}} {{^isListContainer}} + {{^useSingleRequestParameter}} if ({{paramName}} !== undefined) { {{#isDateTime}} localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? @@ -131,17 +161,43 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur {{/isDate}} {{/isDateTime}} } + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + if (requestParameters.{{paramName}} !== undefined) { + {{#isDateTime}} + localVarQueryParameter['{{baseName}}'] = (requestParameters.{{paramName}} as any instanceof Date) ? + (requestParameters.{{paramName}} as any).toISOString() : requestParameters.{{paramName}}; + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + localVarQueryParameter['{{baseName}}'] = (requestParameters.{{paramName}} as any instanceof Date) ? + (requestParameters.{{paramName}} as any).toISOString().substr(0,10) : requestParameters.{{paramName}}; + {{/isDate}} + {{^isDate}} + localVarQueryParameter['{{baseName}}'] = requestParameters.{{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + {{/useSingleRequestParameter}} {{/isListContainer}} - {{/queryParams}} {{#headerParams}} {{#isListContainer}} - if ({{paramName}}) { + {{^useSingleRequestParameter}} + if ({{paramName}}) { let mapped = {{paramName}}.map(value => (<any>"{{{dataType}}}" !== "Array<string>") ? JSON.stringify(value) : (value || "")); localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); - } + } + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + if (requestParameters.{{paramName}}) { + let mapped = requestParameters.{{paramName}}.map(value => (<any>"{{{dataType}}}" !== "Array<string>") ? JSON.stringify(value) : (value || "")); + localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + } + {{/useSingleRequestParameter}} {{/isListContainer}} {{^isListContainer}} + {{^useSingleRequestParameter}} if ({{paramName}} !== undefined && {{paramName}} !== null) { {{#isString}} localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); @@ -150,30 +206,65 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur localVarHeaderParameter['{{baseName}}'] = String(JSON.stringify({{paramName}})); {{/isString}} } + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) { + {{#isString}} + localVarHeaderParameter['{{baseName}}'] = String(requestParameters.{{paramName}}); + {{/isString}} + {{^isString}} + localVarHeaderParameter['{{baseName}}'] = String(JSON.stringify(requestParameters.{{paramName}})); + {{/isString}} + } + {{/useSingleRequestParameter}} {{/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}} + {{^useSingleRequestParameter}} + {{#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}} + {{/useSingleRequestParameter}} + {{#useSingleRequestParameter}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { + {{#isCollectionFormatMulti}} + requestParameters.{{paramName}}.forEach((element) => { + localVarFormParams.append('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}}{{^multipartFormData}} + localVarFormParams.set('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}} + {{/isCollectionFormatMulti}} + }{{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined) { {{^multipartFormData}} + localVarFormParams.set('{{baseName}}', requestParameters.{{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', requestParameters.{{paramName}} as any);{{/multipartFormData}} + } + {{/isListContainer}} + {{/useSingleRequestParameter}} + {{/formParams}} + {{/vendorExtensions}} + {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}} localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} @@ -196,8 +287,14 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; {{/hasFormParams}} {{#bodyParam}} +{{^useSingleRequestParameter}} const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} !== undefined ? {{paramName}} : {}) : ({{paramName}} || ""); +{{/useSingleRequestParameter}} +{{#useSingleRequestParameter}} + const needsSerialization = (typeof requestParameters.{{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.{{paramName}} !== undefined ? requestParameters.{{paramName}} : {}) : (requestParameters.{{paramName}} || ""); +{{/useSingleRequestParameter}} {{/bodyParam}} return { @@ -228,6 +325,7 @@ export const {{classname}}Fp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ +{{^useSingleRequestParameter}} async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>> { const localVarAxiosArgs = await {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { @@ -235,6 +333,16 @@ export const {{classname}}Fp = function(configuration?: Configuration) { return axios.request(axiosRequestArgs); }; }, +{{/useSingleRequestParameter}} +{{#useSingleRequestParameter}} + async {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request,{{/allParams.0}}options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>> { + const localVarAxiosArgs = await {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams.0}}requestParameters,{{/allParams.0}}options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, +{{/useSingleRequestParameter}} {{/operation}} } }; @@ -258,9 +366,16 @@ export const {{classname}}Factory = function (configuration?: Configuration, bas * @param {*} [options] Override http request option. * @throws {RequiredError} */ +{{^useSingleRequestParameter}} {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath)); }, +{{/useSingleRequestParameter}} +{{#useSingleRequestParameter}} + {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + return {{classname}}Fp(configuration).{{nickname}}({{#allParams.0}}requestParameters, {{/allParams.0}}options).then((request) => request(axios, basePath)); + }, +{{/useSingleRequestParameter}} {{/operation}} }; }; @@ -279,15 +394,21 @@ export interface {{classname}}Interface { {{#summary}} * @summary {{&summary}} {{/summary}} +{{^useSingleRequestParameter}} {{#allParams}} * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} {{/allParams}} +{{/useSingleRequestParameter}} * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof {{classname}}Interface */ +{{^useSingleRequestParameter}} {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>; - +{{/useSingleRequestParameter}} +{{#useSingleRequestParameter}} + {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any): AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>; +{{/useSingleRequestParameter}} {{/operation}} } @@ -318,10 +439,31 @@ export class {{classname}} extends BaseAPI { * @throws {RequiredError} * @memberof {{classname}} */ +{{^useSingleRequestParameter}} public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath)); } +{{/useSingleRequestParameter}} +{{#useSingleRequestParameter}} + public {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any) { + return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}requestParameters, {{/allParams.0}}options).then((request) => request(this.axios, this.basePath)); + } +{{/useSingleRequestParameter}} {{/operation}} } +{{#useSingleRequestParameter}} +{{#operation}} +{{#allParams.0}} + export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request { + {{#allParams}} + /** + * {{{description}}} + */ + {{paramName}}{{^required}}?{{/required}}: {{=<% %>=}}<%&dataType%><%={{ }}=%>{{#isNullable}} | null{{/isNullable}}; + {{/allParams}} + } +{{/allParams.0}} +{{/operation}} +{{/useSingleRequestParameter}} {{/operations}} diff --git a/samples/client/petstore/typescript-axios/builds/default/api.ts b/samples/client/petstore/typescript-axios/builds/default/api.ts index e252e289aa111a3ecdbcee251cd0a1356ac014a7..270b14830a872df748466bd50df1d8463c2cacfa 100644 --- a/samples/client/petstore/typescript-axios/builds/default/api.ts +++ b/samples/client/petstore/typescript-axios/builds/default/api.ts @@ -385,7 +385,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -433,7 +432,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -574,14 +572,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -633,14 +631,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; @@ -1542,12 +1540,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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 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 e252e289aa111a3ecdbcee251cd0a1356ac014a7..270b14830a872df748466bd50df1d8463c2cacfa 100644 --- a/samples/client/petstore/typescript-axios/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-axios/builds/es6-target/api.ts @@ -385,7 +385,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -433,7 +432,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -574,14 +572,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -633,14 +631,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; @@ -1542,12 +1540,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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 diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.gitignore b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..205d8013f46fecc76f4ccd355958286cf2cc9ccf --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.npmignore b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..999d88df6939a13529be54ef2e68fb3248257ad8 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.openapi-generator-ignore new file mode 100644 index 0000000000000000000000000000000000000000..7484ee590a3894506cf063799b885428f95a71be --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.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/use-single-request-parameter/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.openapi-generator/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..d99e7162d01f35766e7a53f78b6acb6f7d84f1c3 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/README.md b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/README.md new file mode 100644 index 0000000000000000000000000000000000000000..79a1afb768a9a8e9fde8a8367d37fd4615083722 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/README.md @@ -0,0 +1,45 @@ +## @openapitools/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 @openapitools/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/use-single-request-parameter/api.ts b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/api.ts new file mode 100644 index 0000000000000000000000000000000000000000..df24ebcd53cb996be8b0d73d2b37f1d124fc36e6 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/api.ts @@ -0,0 +1,2082 @@ +// 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. + * + * The version of the OpenAPI document: 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 globalImportUrl from 'url'; +import { Configuration } from './configuration'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; + +/** + * 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; +} +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} +/** + * 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 {string} + * @memberof Order + */ + shipDate?: string; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: OrderStatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @enum {string} + */ +export enum OrderStatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +} + +/** + * 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<string>} + * @memberof Pet + */ + photoUrls: Array<string>; + /** + * + * @type {Array<Tag>} + * @memberof Pet + */ + tags?: Array<Tag>; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: PetStatusEnum; +} + +/** + * @export + * @enum {string} + */ +export enum PetStatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' +} + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} +/** + * 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; +} + +/** + * 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: async (requestParameters: AddPetRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); + } + const localVarPath = `/pet`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.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: async (requestParameters: DeletePetRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'petId' is not null or undefined + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); + } + const localVarPath = `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))); + const localVarUrlObj = globalImportUrl.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 (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + localVarHeaderParameter['api_key'] = String(requestParameters.apiKey); + } + + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: FindPetsByStatusRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'status' is not null or undefined + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); + } + const localVarPath = `/pet/findByStatus`; + const localVarUrlObj = globalImportUrl.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 (requestParameters.status) { + localVarQueryParameter['status'] = requestParameters.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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<string>} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByTags: async (requestParameters: FindPetsByTagsRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'tags' is not null or undefined + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); + } + const localVarPath = `/pet/findByTags`; + const localVarUrlObj = globalImportUrl.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 (requestParameters.tags) { + localVarQueryParameter['tags'] = requestParameters.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: GetPetByIdRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'petId' is not null or undefined + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); + } + const localVarPath = `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))); + const localVarUrlObj = globalImportUrl.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' + ? await configuration.apiKey("api_key") + : await 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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: UpdatePetRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); + } + const localVarPath = `/pet`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.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: async (requestParameters: UpdatePetWithFormRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'petId' is not null or undefined + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + const localVarPath = `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))); + const localVarUrlObj = globalImportUrl.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 (requestParameters.name !== undefined) { + localVarFormParams.set('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + localVarFormParams.set('status', requestParameters.status as any); + } + + + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: globalImportUrl.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: async (requestParameters: UploadFileRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'petId' is not null or undefined + if (requestParameters.petId === null || requestParameters.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(requestParameters.petId))); + const localVarUrlObj = globalImportUrl.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 (requestParameters.additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + localVarFormParams.append('file', requestParameters.file as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: globalImportUrl.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} + */ + async addPet(requestParameters: AddPetRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).addPet(requestParameters,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} + */ + async deletePet(requestParameters: DeletePetRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).deletePet(requestParameters,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} + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Pet>>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).findPetsByStatus(requestParameters,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<string>} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Pet>>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).findPetsByTags(requestParameters,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} + */ + async getPetById(requestParameters: GetPetByIdRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Pet>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).getPetById(requestParameters,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} + */ + async updatePet(requestParameters: UpdatePetRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).updatePet(requestParameters,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} + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).updatePetWithForm(requestParameters,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} + */ + async uploadFile(requestParameters: UploadFileRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiResponse>> { + const localVarAxiosArgs = await PetApiAxiosParamCreator(configuration).uploadFile(requestParameters,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(requestParameters: AddPetRequest, options?: any): AxiosPromise<void> { + return PetApiFp(configuration).addPet(requestParameters, options).then((request) => request(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(requestParameters: DeletePetRequest, options?: any): AxiosPromise<void> { + return PetApiFp(configuration).deletePet(requestParameters, options).then((request) => request(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(requestParameters: FindPetsByStatusRequest, options?: any): AxiosPromise<Array<Pet>> { + return PetApiFp(configuration).findPetsByStatus(requestParameters, options).then((request) => request(axios, basePath)); + }, + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array<string>} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByTags(requestParameters: FindPetsByTagsRequest, options?: any): AxiosPromise<Array<Pet>> { + return PetApiFp(configuration).findPetsByTags(requestParameters, options).then((request) => request(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(requestParameters: GetPetByIdRequest, options?: any): AxiosPromise<Pet> { + return PetApiFp(configuration).getPetById(requestParameters, options).then((request) => request(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(requestParameters: UpdatePetRequest, options?: any): AxiosPromise<void> { + return PetApiFp(configuration).updatePet(requestParameters, options).then((request) => request(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(requestParameters: UpdatePetWithFormRequest, options?: any): AxiosPromise<void> { + return PetApiFp(configuration).updatePetWithForm(requestParameters, options).then((request) => request(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(requestParameters: UploadFileRequest, options?: any): AxiosPromise<ApiResponse> { + return PetApiFp(configuration).uploadFile(requestParameters, options).then((request) => request(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(requestParameters: AddPetRequest, options?: any) { + return PetApiFp(this.configuration).addPet(requestParameters, options).then((request) => request(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(requestParameters: DeletePetRequest, options?: any) { + return PetApiFp(this.configuration).deletePet(requestParameters, options).then((request) => request(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(requestParameters: FindPetsByStatusRequest, options?: any) { + return PetApiFp(this.configuration).findPetsByStatus(requestParameters, options).then((request) => request(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<string>} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public findPetsByTags(requestParameters: FindPetsByTagsRequest, options?: any) { + return PetApiFp(this.configuration).findPetsByTags(requestParameters, options).then((request) => request(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(requestParameters: GetPetByIdRequest, options?: any) { + return PetApiFp(this.configuration).getPetById(requestParameters, options).then((request) => request(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(requestParameters: UpdatePetRequest, options?: any) { + return PetApiFp(this.configuration).updatePet(requestParameters, options).then((request) => request(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(requestParameters: UpdatePetWithFormRequest, options?: any) { + return PetApiFp(this.configuration).updatePetWithForm(requestParameters, options).then((request) => request(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(requestParameters: UploadFileRequest, options?: any) { + return PetApiFp(this.configuration).uploadFile(requestParameters, options).then((request) => request(this.axios, this.basePath)); + } + +} + export interface AddPetRequest { + /** + * Pet object that needs to be added to the store + */ + body: Pet; + } + export interface DeletePetRequest { + /** + * Pet id to delete + */ + petId: number; + /** + * + */ + apiKey?: string; + } + export interface FindPetsByStatusRequest { + /** + * Status values that need to be considered for filter + */ + status: Array<'available' | 'pending' | 'sold'>; + } + export interface FindPetsByTagsRequest { + /** + * Tags to filter by + */ + tags: Array<string>; + } + export interface GetPetByIdRequest { + /** + * ID of pet to return + */ + petId: number; + } + export interface UpdatePetRequest { + /** + * Pet object that needs to be added to the store + */ + body: Pet; + } + export interface UpdatePetWithFormRequest { + /** + * ID of pet that needs to be updated + */ + petId: number; + /** + * Updated name of the pet + */ + name?: string; + /** + * Updated status of the pet + */ + status?: string; + } + export interface UploadFileRequest { + /** + * ID of pet to update + */ + petId: number; + /** + * Additional data to pass to server + */ + additionalMetadata?: string; + /** + * file to upload + */ + file?: any; + } + + +/** + * 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: async (requestParameters: DeleteOrderRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'orderId' is not null or undefined + if (requestParameters.orderId === null || requestParameters.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(requestParameters.orderId))); + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (options: any = {}): Promise<RequestArgs> => { + const localVarPath = `/store/inventory`; + const localVarUrlObj = globalImportUrl.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' + ? await configuration.apiKey("api_key") + : await 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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: GetOrderByIdRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'orderId' is not null or undefined + if (requestParameters.orderId === null || requestParameters.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(requestParameters.orderId))); + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: PlaceOrderRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); + } + const localVarPath = `/store/order`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.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} + */ + async deleteOrder(requestParameters: DeleteOrderRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await StoreApiAxiosParamCreator(configuration).deleteOrder(requestParameters,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} + */ + async getInventory(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: number; }>> { + const localVarAxiosArgs = await 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} + */ + async getOrderById(requestParameters: GetOrderByIdRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Order>> { + const localVarAxiosArgs = await StoreApiAxiosParamCreator(configuration).getOrderById(requestParameters,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} + */ + async placeOrder(requestParameters: PlaceOrderRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Order>> { + const localVarAxiosArgs = await StoreApiAxiosParamCreator(configuration).placeOrder(requestParameters,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(requestParameters: DeleteOrderRequest, options?: any): AxiosPromise<void> { + return StoreApiFp(configuration).deleteOrder(requestParameters, options).then((request) => request(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): AxiosPromise<{ [key: string]: number; }> { + return StoreApiFp(configuration).getInventory(options).then((request) => request(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(requestParameters: GetOrderByIdRequest, options?: any): AxiosPromise<Order> { + return StoreApiFp(configuration).getOrderById(requestParameters, options).then((request) => request(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(requestParameters: PlaceOrderRequest, options?: any): AxiosPromise<Order> { + return StoreApiFp(configuration).placeOrder(requestParameters, options).then((request) => request(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(requestParameters: DeleteOrderRequest, options?: any) { + return StoreApiFp(this.configuration).deleteOrder(requestParameters, options).then((request) => request(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).then((request) => request(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(requestParameters: GetOrderByIdRequest, options?: any) { + return StoreApiFp(this.configuration).getOrderById(requestParameters, options).then((request) => request(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(requestParameters: PlaceOrderRequest, options?: any) { + return StoreApiFp(this.configuration).placeOrder(requestParameters, options).then((request) => request(this.axios, this.basePath)); + } + +} + export interface DeleteOrderRequest { + /** + * ID of the order that needs to be deleted + */ + orderId: string; + } + export interface GetOrderByIdRequest { + /** + * ID of pet that needs to be fetched + */ + orderId: number; + } + export interface PlaceOrderRequest { + /** + * order placed for purchasing the pet + */ + body: Order; + } + + +/** + * 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: async (requestParameters: CreateUserRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); + } + const localVarPath = `/user`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput: async (requestParameters: CreateUsersWithArrayInputRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } + const localVarPath = `/user/createWithArray`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput: async (requestParameters: CreateUsersWithListInputRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'body' is not null or undefined + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); + } + const localVarPath = `/user/createWithList`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.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: async (requestParameters: DeleteUserRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'username' is not null or undefined + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); + } + const localVarPath = `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))); + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: GetUserByNameRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'username' is not null or undefined + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); + } + const localVarPath = `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))); + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: LoginUserRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'username' is not null or undefined + if (requestParameters.username === null || requestParameters.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 (requestParameters.password === null || requestParameters.password === undefined) { + throw new RequiredError('password','Required parameter password was null or undefined when calling loginUser.'); + } + const localVarPath = `/user/login`; + const localVarUrlObj = globalImportUrl.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 (requestParameters.username !== undefined) { + localVarQueryParameter['username'] = requestParameters.username; + } + if (requestParameters.password !== undefined) { + localVarQueryParameter['password'] = requestParameters.password; + } + + + localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query}; + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser: async (options: any = {}): Promise<RequestArgs> => { + const localVarPath = `/user/logout`; + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: globalImportUrl.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: async (requestParameters: UpdateUserRequest, options: any = {}): Promise<RequestArgs> => { + // verify required parameter 'username' is not null or undefined + if (requestParameters.username === null || requestParameters.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 (requestParameters.body === null || requestParameters.body === undefined) { + throw new RequiredError('body','Required parameter body was null or undefined when calling updateUser.'); + } + const localVarPath = `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))); + const localVarUrlObj = globalImportUrl.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; + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + const needsSerialization = (typeof requestParameters.body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(requestParameters.body !== undefined ? requestParameters.body : {}) : (requestParameters.body || ""); + + return { + url: globalImportUrl.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} + */ + async createUser(requestParameters: CreateUserRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).createUser(requestParameters,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<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).createUsersWithArrayInput(requestParameters,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<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).createUsersWithListInput(requestParameters,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} + */ + async deleteUser(requestParameters: DeleteUserRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).deleteUser(requestParameters,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} + */ + async getUserByName(requestParameters: GetUserByNameRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<User>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).getUserByName(requestParameters,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} + */ + async loginUser(requestParameters: LoginUserRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).loginUser(requestParameters,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} + */ + async logoutUser(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await 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} + */ + async updateUser(requestParameters: UpdateUserRequest,options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { + const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).updateUser(requestParameters,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(requestParameters: CreateUserRequest, options?: any): AxiosPromise<void> { + return UserApiFp(configuration).createUser(requestParameters, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest, options?: any): AxiosPromise<void> { + return UserApiFp(configuration).createUsersWithArrayInput(requestParameters, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest, options?: any): AxiosPromise<void> { + return UserApiFp(configuration).createUsersWithListInput(requestParameters, options).then((request) => request(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(requestParameters: DeleteUserRequest, options?: any): AxiosPromise<void> { + return UserApiFp(configuration).deleteUser(requestParameters, options).then((request) => request(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(requestParameters: GetUserByNameRequest, options?: any): AxiosPromise<User> { + return UserApiFp(configuration).getUserByName(requestParameters, options).then((request) => request(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(requestParameters: LoginUserRequest, options?: any): AxiosPromise<string> { + return UserApiFp(configuration).loginUser(requestParameters, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser(options?: any): AxiosPromise<void> { + return UserApiFp(configuration).logoutUser(options).then((request) => request(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(requestParameters: UpdateUserRequest, options?: any): AxiosPromise<void> { + return UserApiFp(configuration).updateUser(requestParameters, options).then((request) => request(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(requestParameters: CreateUserRequest, options?: any) { + return UserApiFp(this.configuration).createUser(requestParameters, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(requestParameters, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array<User>} body List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(requestParameters, options).then((request) => request(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(requestParameters: DeleteUserRequest, options?: any) { + return UserApiFp(this.configuration).deleteUser(requestParameters, options).then((request) => request(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(requestParameters: GetUserByNameRequest, options?: any) { + return UserApiFp(this.configuration).getUserByName(requestParameters, options).then((request) => request(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(requestParameters: LoginUserRequest, options?: any) { + return UserApiFp(this.configuration).loginUser(requestParameters, options).then((request) => request(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).then((request) => request(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(requestParameters: UpdateUserRequest, options?: any) { + return UserApiFp(this.configuration).updateUser(requestParameters, options).then((request) => request(this.axios, this.basePath)); + } + +} + export interface CreateUserRequest { + /** + * Created user object + */ + body: User; + } + export interface CreateUsersWithArrayInputRequest { + /** + * List of user object + */ + body: Array<User>; + } + export interface CreateUsersWithListInputRequest { + /** + * List of user object + */ + body: Array<User>; + } + export interface DeleteUserRequest { + /** + * The name that needs to be deleted + */ + username: string; + } + export interface GetUserByNameRequest { + /** + * The name that needs to be fetched. Use user1 for testing. + */ + username: string; + } + export interface LoginUserRequest { + /** + * The user name for login + */ + username: string; + /** + * The password for login in clear text + */ + password: string; + } + export interface UpdateUserRequest { + /** + * name that need to be deleted + */ + username: string; + /** + * Updated user object + */ + body: User; + } + + diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/base.ts b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/base.ts new file mode 100644 index 0000000000000000000000000000000000000000..71e2f198af3e328a7ea8a2e5c77bcd425a1e1f91 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/base.ts @@ -0,0 +1,70 @@ +// 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. + * + * The version of the OpenAPI document: 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"; +// Some imports not used depending on template conditions +// @ts-ignore +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/use-single-request-parameter/configuration.ts b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/configuration.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d5dc74ee608dbc9a42c228840c572b372e685b0 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/configuration.ts @@ -0,0 +1,75 @@ +// 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. + * + * The version of the OpenAPI document: 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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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; + this.baseOptions = param.baseOptions; + } +} diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/git_push.sh b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/git_push.sh new file mode 100644 index 0000000000000000000000000000000000000000..ced3be2b0c7b2349ff06d18da19d4b31435c9fa6 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/git_push.sh @@ -0,0 +1,58 @@ +#!/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" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +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://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${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://${git_host}/${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/use-single-request-parameter/index.ts b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cb247adefaf29c9fd63a118193dbc7d6333788a --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/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. + * + * The version of the OpenAPI document: 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/use-single-request-parameter/package.json b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a45d2102eae3bbcff100033e7a6f0bddf2fb2410 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/package.json @@ -0,0 +1,30 @@ +{ + "name": "@openapitools/typescript-axios-petstore", + "version": "1.0.0", + "description": "OpenAPI client for @openapitools/typescript-axios-petstore", + "author": "OpenAPI-Generator Contributors", + "keywords": [ + "axios", + "typescript", + "openapi-client", + "openapi-generator", + "@openapitools/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.19.2" + }, + "devDependencies": { + "@types/node": "^12.11.5", + "typescript": "^3.6.4" + }, + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/tsconfig.json b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..2f27acb9fd94489db28bb02d7e4007b1cb8e6968 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/use-single-request-parameter/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ], + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts b/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts index 9a223021114c2cc42f1ff6739baa5b26cab3f5f3..fdc9d78c174b7d983ce7601ee3e6f9af2bcf9788 100644 --- a/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts @@ -327,10 +327,10 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) localVarHeaderParameter['header1'] = String(JSON.stringify(header1)); } - if (header2) { - let mapped = header2.map(value => (<any>"Array<Pet>" !== "Array<string>") ? JSON.stringify(value) : (value || "")); - localVarHeaderParameter['header2'] = mapped.join(COLLECTION_FORMATS["csv"]); - } + if (header2) { + let mapped = header2.map(value => (<any>"Array<Pet>" !== "Array<string>") ? JSON.stringify(value) : (value || "")); + localVarHeaderParameter['header2'] = mapped.join(COLLECTION_FORMATS["csv"]); + } @@ -434,7 +434,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -482,7 +481,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -623,14 +621,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -682,14 +680,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; @@ -1597,12 +1595,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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 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 14c956210b942cc863231ec42345efa3302b840f..f0b227b4f137edcafdee5b96a93fdf49684da16a 100644 --- a/samples/client/petstore/typescript-axios/builds/with-interfaces/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-interfaces/api.ts @@ -385,7 +385,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -433,7 +432,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -574,14 +572,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -633,14 +631,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; @@ -894,7 +892,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ addPet(body: Pet, options?: any): AxiosPromise<void>; - /** * * @summary Deletes a pet @@ -905,7 +902,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ deletePet(petId: number, apiKey?: string, options?: any): AxiosPromise<void>; - /** * Multiple status values can be provided with comma separated strings * @summary Finds Pets by status @@ -915,7 +911,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): AxiosPromise<Array<Pet>>; - /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @summary Finds Pets by tags @@ -925,7 +920,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ findPetsByTags(tags: Array<string>, options?: any): AxiosPromise<Array<Pet>>; - /** * Returns a single pet * @summary Find pet by ID @@ -935,7 +929,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ getPetById(petId: number, options?: any): AxiosPromise<Pet>; - /** * * @summary Update an existing pet @@ -945,7 +938,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ updatePet(body: Pet, options?: any): AxiosPromise<void>; - /** * * @summary Updates a pet in the store with form data @@ -957,7 +949,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ updatePetWithForm(petId: number, name?: string, status?: string, options?: any): AxiosPromise<void>; - /** * * @summary uploads an image @@ -969,7 +960,6 @@ export interface PetApiInterface { * @memberof PetApiInterface */ uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): AxiosPromise<ApiResponse>; - } /** @@ -1368,7 +1358,6 @@ export interface StoreApiInterface { * @memberof StoreApiInterface */ deleteOrder(orderId: string, options?: any): AxiosPromise<void>; - /** * Returns a map of status codes to quantities * @summary Returns pet inventories by status @@ -1377,7 +1366,6 @@ export interface StoreApiInterface { * @memberof StoreApiInterface */ getInventory(options?: any): AxiosPromise<{ [key: string]: number; }>; - /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @summary Find purchase order by ID @@ -1387,7 +1375,6 @@ export interface StoreApiInterface { * @memberof StoreApiInterface */ getOrderById(orderId: number, options?: any): AxiosPromise<Order>; - /** * * @summary Place an order for a pet @@ -1397,7 +1384,6 @@ export interface StoreApiInterface { * @memberof StoreApiInterface */ placeOrder(body: Order, options?: any): AxiosPromise<Order>; - } /** @@ -1682,12 +1668,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -2005,7 +1989,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ createUser(body: User, options?: any): AxiosPromise<void>; - /** * * @summary Creates list of users with given input array @@ -2015,7 +1998,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ createUsersWithArrayInput(body: Array<User>, options?: any): AxiosPromise<void>; - /** * * @summary Creates list of users with given input array @@ -2025,7 +2007,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ createUsersWithListInput(body: Array<User>, options?: any): AxiosPromise<void>; - /** * This can only be done by the logged in user. * @summary Delete user @@ -2035,7 +2016,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ deleteUser(username: string, options?: any): AxiosPromise<void>; - /** * * @summary Get user by user name @@ -2045,7 +2025,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ getUserByName(username: string, options?: any): AxiosPromise<User>; - /** * * @summary Logs user into the system @@ -2056,7 +2035,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ loginUser(username: string, password: string, options?: any): AxiosPromise<string>; - /** * * @summary Logs out current logged in user session @@ -2065,7 +2043,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ logoutUser(options?: any): AxiosPromise<void>; - /** * This can only be done by the logged in user. * @summary Updated user @@ -2076,7 +2053,6 @@ export interface UserApiInterface { * @memberof UserApiInterface */ updateUser(username: string, body: User, options?: any): AxiosPromise<void>; - } /** 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 index 1358cf311a4217ff15681894c1bed170acbc3c23..bec7d020311910c3f2a18086380f5c4d30d68d44 100644 --- 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 @@ -161,7 +161,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -209,7 +208,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -350,14 +348,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -409,14 +407,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 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 index 7319fd816bd0e20f92f6901138118340f0e52660..18bde499dd8073f21468da101d1ddb655ad581f9 100644 --- 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 @@ -245,12 +245,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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 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 e252e289aa111a3ecdbcee251cd0a1356ac014a7..270b14830a872df748466bd50df1d8463c2cacfa 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 @@ -385,7 +385,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -433,7 +432,6 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) 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 @@ -574,14 +572,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } - - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } - + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; @@ -633,14 +631,14 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration) } - if (additionalMetadata !== undefined) { - localVarFormParams.append('additionalMetadata', additionalMetadata as any); - } - - if (file !== undefined) { - localVarFormParams.append('file', file as any); - } - + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; @@ -1542,12 +1540,10 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration) 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