From 84f8a4ac3b548edf1db92c78abf3d4e8517e2a47 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:50:48 -0800 Subject: [PATCH] chore(open-api): remove no-op patch (#6649) * chore: remove no-op patch * address code review --- open-api/bin/generate-open-api.sh | 6 +- .../templates/typescript/apiInner.mustache | 391 ------------------ .../typescript/apiInner.mustache.orig | 390 ----------------- .../typescript/apiInner.mustache.patch | 14 - 4 files changed, 1 insertion(+), 800 deletions(-) delete mode 100644 open-api/templates/typescript/apiInner.mustache delete mode 100644 open-api/templates/typescript/apiInner.mustache.orig delete mode 100644 open-api/templates/typescript/apiInner.mustache.patch diff --git a/open-api/bin/generate-open-api.sh b/open-api/bin/generate-open-api.sh index be5da7f9f5..f18968e956 100755 --- a/open-api/bin/generate-open-api.sh +++ b/open-api/bin/generate-open-api.sh @@ -19,11 +19,7 @@ function dart { function typescript { rm -rf ./typescript-sdk/client - cd ./templates/typescript - wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/$OPENAPI_GENERATOR_VERSION/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache - patch -u apiInner.mustache < apiInner.mustache.patch - cd ../.. - npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ./typescript-sdk/client -t ./templates/typescript --additional-properties=useSingleRequestParameter=true + npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ./typescript-sdk/client --additional-properties=useSingleRequestParameter=true npm --prefix typescript-sdk ci && npm --prefix typescript-sdk run build } diff --git a/open-api/templates/typescript/apiInner.mustache b/open-api/templates/typescript/apiInner.mustache deleted file mode 100644 index 65bf745061..0000000000 --- a/open-api/templates/typescript/apiInner.mustache +++ /dev/null @@ -1,391 +0,0 @@ -{{#withSeparateModelsAndApi}} -/* tslint:disable */ -/* eslint-disable */ -{{>licenseInfo}} - -import type { Configuration } from '{{apiRelativeToRoot}}configuration'; -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; -{{#withNodeImports}} -// URLSearchParams not necessarily used -// @ts-ignore -import { URL, URLSearchParams } from 'url'; -{{#multipartFormData}} -import FormData from 'form-data' -{{/multipartFormData}} -{{/withNodeImports}} -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '{{apiRelativeToRoot}}common'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '{{apiRelativeToRoot}}base'; -{{#imports}} -// @ts-ignore -import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}'; -{{/imports}} -{{/withSeparateModelsAndApi}} -{{^withSeparateModelsAndApi}} -{{/withSeparateModelsAndApi}} -{{#operations}} -/** - * {{classname}} - axios parameter creator{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - {{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: AxiosRequestConfig = {}): Promise => { - {{#allParams}} - {{#required}} - // verify required parameter '{{paramName}}' is not null or undefined - assertParamExists('{{nickname}}', '{{paramName}}', {{paramName}}) - {{/required}} - {{/allParams}} - const localVarPath = `{{{path}}}`{{#pathParams}} - .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} - const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}((configuration && configuration.formDataCtor) || FormData)(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} - - {{#authMethods}} - // authentication {{name}} required - {{#isApiKey}} - {{#isKeyInHeader}} - await setApiKeyToObject(localVarHeaderParameter, "{{keyParamName}}", configuration) - {{/isKeyInHeader}} - {{#isKeyInQuery}} - await setApiKeyToObject(localVarQueryParameter, "{{keyParamName}}", configuration) - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isBasicBasic}} - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - {{/isBasicBasic}} - {{#isBasicBearer}} - // http bearer authentication required - await setBearerAuthToObject(localVarHeaderParameter, configuration) - {{/isBasicBearer}} - {{#isOAuth}} - // oauth required - await setOAuthToObject(localVarHeaderParameter, "{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}], configuration) - {{/isOAuth}} - - {{/authMethods}} - {{#queryParams}} - {{#isArray}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - {{#uniqueItems}} - localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}); - {{/uniqueItems}} - {{^uniqueItems}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/uniqueItems}} - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - {{#uniqueItems}} - localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}}); - {{/uniqueItems}} - {{^uniqueItems}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); - {{/uniqueItems}} - {{/isCollectionFormatMulti}} - } - {{/isArray}} - {{^isArray}} - if ({{paramName}} !== undefined) { - {{#isDateTime}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? - ({{paramName}} as any).toISOString() : - {{paramName}}; - {{/isDateTime}} - {{^isDateTime}} - {{#isDate}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? - ({{paramName}} as any).toISOString().substr(0,10) : - {{paramName}}; - {{/isDate}} - {{^isDate}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/isDate}} - {{/isDateTime}} - } - {{/isArray}} - - {{/queryParams}} - {{#headerParams}} - {{#isArray}} - if ({{paramName}}) { - {{#uniqueItems}} - let mapped = Array.from({{paramName}}).map(value => ("{{{dataType}}}" !== "Set") ? JSON.stringify(value) : (value || "")); - {{/uniqueItems}} - {{^uniqueItems}} - let mapped = {{paramName}}.map(value => ("{{{dataType}}}" !== "Array") ? JSON.stringify(value) : (value || "")); - {{/uniqueItems}} - localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); - } - {{/isArray}} - {{^isArray}} - {{! `val == null` covers for both `null` and `undefined`}} - if ({{paramName}} != null) { - {{#isString}} - localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); - {{/isString}} - {{^isString}} - {{! isString is falsy also for $ref that defines a string or enum type}} - localVarHeaderParameter['{{baseName}}'] = typeof {{paramName}} === 'string' - ? {{paramName}} - : JSON.stringify({{paramName}}); - {{/isString}} - } - {{/isArray}} - - {{/headerParams}} - {{#vendorExtensions}} - {{#formParams}} - {{#isArray}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}})); - {{/isCollectionFormatMulti}} - }{{/isArray}} - {{^isArray}} - if ({{paramName}} !== undefined) { {{^multipartFormData}} - localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}} - localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isEnum}} - localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isEnum}}{{^isEnum}} - localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isEnum}}{{/isPrimitiveType}}{{/multipartFormData}} - }{{/isArray}} - {{/formParams}}{{/vendorExtensions}} - {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} - {{/hasFormParams}}{{/vendorExtensions}} - {{#bodyParam}} - {{^consumes}} - localVarHeaderParameter['Content-Type'] = 'application/json'; - {{/consumes}} - {{#consumes.0}} - localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; - {{/consumes.0}} - - {{/bodyParam}} - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions,{{#hasFormParams}}{{#multipartFormData}} ...(localVarFormParams as any).getHeaders?.(),{{/multipartFormData}}{{/hasFormParams}} ...options.headers}; - {{#hasFormParams}} - localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; - {{/hasFormParams}} - {{#bodyParam}} - localVarRequestOptions.data = serializeDataIfNeeded({{paramName}}, localVarRequestOptions, configuration) - {{/bodyParam}} - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - {{/operation}} - } -}; - -/** - * {{classname}} - functional programming interface{{#description}} - * {{{.}}}{{/description}} - * @export - */ -export const {{classname}}Fp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration) - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - {{/operation}} - } -}; - -/** - * {{classname}} - factory interface{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = {{classname}}Fp(configuration) - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#useSingleRequestParameter}} - {{#allParams.0}} - * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. - {{/allParams.0}} - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - {{/useSingleRequestParameter}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - {{#useSingleRequestParameter}} - {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: AxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { - return localVarFp.{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(axios, basePath)); - }, - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { - return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath)); - }, - {{/useSingleRequestParameter}} - {{/operation}} - }; -}; - -{{#withInterfaces}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export interface {{classname}}Interface { -{{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - * @memberof {{classname}}Interface - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; - -{{/operation}} -} - -{{/withInterfaces}} -{{#useSingleRequestParameter}} -{{#operation}} -{{#allParams.0}} -/** - * Request parameters for {{nickname}} operation in {{classname}}. - * @export - * @interface {{classname}}{{operationIdCamelCase}}Request - */ -export interface {{classname}}{{operationIdCamelCase}}Request { - {{#allParams}} - /** - * {{description}} - * @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> - * @memberof {{classname}}{{operationIdCamelCase}} - */ - readonly {{paramName}}{{^required}}?{{/required}}: {{{dataType}}} - {{^-last}} - - {{/-last}} - {{/allParams}} -} - -{{/allParams.0}} -{{/operation}} -{{/useSingleRequestParameter}} -/** - * {{classname}} - object-oriented interface{{#description}} - * {{{.}}}{{/description}} - * @export - * @class {{classname}} - * @extends {BaseAPI} - */ -{{#withInterfaces}} -export class {{classname}} extends BaseAPI implements {{classname}}Interface { -{{/withInterfaces}} -{{^withInterfaces}} -export class {{classname}} extends BaseAPI { -{{/withInterfaces}} - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#useSingleRequestParameter}} - {{#allParams.0}} - * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. - {{/allParams.0}} - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - {{/useSingleRequestParameter}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - * @memberof {{classname}} - */ - {{#useSingleRequestParameter}} - public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: AxiosRequestConfig) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath)); - } - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath)); - } - {{/useSingleRequestParameter}} - {{^-last}} - - {{/-last}} - {{/operation}} -} -{{/operations}} diff --git a/open-api/templates/typescript/apiInner.mustache.orig b/open-api/templates/typescript/apiInner.mustache.orig deleted file mode 100644 index 4cb65b7f1b..0000000000 --- a/open-api/templates/typescript/apiInner.mustache.orig +++ /dev/null @@ -1,390 +0,0 @@ -{{#withSeparateModelsAndApi}} -/* tslint:disable */ -/* eslint-disable */ -{{>licenseInfo}} - -import type { Configuration } from '{{apiRelativeToRoot}}configuration'; -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; -{{#withNodeImports}} -// URLSearchParams not necessarily used -// @ts-ignore -import { URL, URLSearchParams } from 'url'; -{{#multipartFormData}} -import FormData from 'form-data' -{{/multipartFormData}} -{{/withNodeImports}} -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '{{apiRelativeToRoot}}common'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '{{apiRelativeToRoot}}base'; -{{#imports}} -// @ts-ignore -import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}'; -{{/imports}} -{{/withSeparateModelsAndApi}} -{{^withSeparateModelsAndApi}} -{{/withSeparateModelsAndApi}} -{{#operations}} -/** - * {{classname}} - axios parameter creator{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - {{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: AxiosRequestConfig = {}): Promise => { - {{#allParams}} - {{#required}} - // verify required parameter '{{paramName}}' is not null or undefined - assertParamExists('{{nickname}}', '{{paramName}}', {{paramName}}) - {{/required}} - {{/allParams}} - const localVarPath = `{{{path}}}`{{#pathParams}} - .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} - const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}((configuration && configuration.formDataCtor) || FormData)(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} - - {{#authMethods}} - // authentication {{name}} required - {{#isApiKey}} - {{#isKeyInHeader}} - await setApiKeyToObject(localVarHeaderParameter, "{{keyParamName}}", configuration) - {{/isKeyInHeader}} - {{#isKeyInQuery}} - await setApiKeyToObject(localVarQueryParameter, "{{keyParamName}}", configuration) - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isBasicBasic}} - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - {{/isBasicBasic}} - {{#isBasicBearer}} - // http bearer authentication required - await setBearerAuthToObject(localVarHeaderParameter, configuration) - {{/isBasicBearer}} - {{#isOAuth}} - // oauth required - await setOAuthToObject(localVarHeaderParameter, "{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}], configuration) - {{/isOAuth}} - - {{/authMethods}} - {{#queryParams}} - {{#isArray}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - {{#uniqueItems}} - localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}); - {{/uniqueItems}} - {{^uniqueItems}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/uniqueItems}} - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - {{#uniqueItems}} - localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}}); - {{/uniqueItems}} - {{^uniqueItems}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); - {{/uniqueItems}} - {{/isCollectionFormatMulti}} - } - {{/isArray}} - {{^isArray}} - if ({{paramName}} !== undefined) { - {{#isDateTime}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? - ({{paramName}} as any).toISOString() : - {{paramName}}; - {{/isDateTime}} - {{^isDateTime}} - {{#isDate}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? - ({{paramName}} as any).toISOString().substr(0,10) : - {{paramName}}; - {{/isDate}} - {{^isDate}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/isDate}} - {{/isDateTime}} - } - {{/isArray}} - - {{/queryParams}} - {{#headerParams}} - {{#isArray}} - if ({{paramName}}) { - {{#uniqueItems}} - let mapped = Array.from({{paramName}}).map(value => ("{{{dataType}}}" !== "Set") ? JSON.stringify(value) : (value || "")); - {{/uniqueItems}} - {{^uniqueItems}} - let mapped = {{paramName}}.map(value => ("{{{dataType}}}" !== "Array") ? JSON.stringify(value) : (value || "")); - {{/uniqueItems}} - localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); - } - {{/isArray}} - {{^isArray}} - {{! `val == null` covers for both `null` and `undefined`}} - if ({{paramName}} != null) { - {{#isString}} - localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); - {{/isString}} - {{^isString}} - {{! isString is falsy also for $ref that defines a string or enum type}} - localVarHeaderParameter['{{baseName}}'] = typeof {{paramName}} === 'string' - ? {{paramName}} - : JSON.stringify({{paramName}}); - {{/isString}} - } - {{/isArray}} - - {{/headerParams}} - {{#vendorExtensions}} - {{#formParams}} - {{#isArray}} - if ({{paramName}}) { - {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}})); - {{/isCollectionFormatMulti}} - }{{/isArray}} - {{^isArray}} - if ({{paramName}} !== undefined) { {{^multipartFormData}} - localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}} - localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}} - localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isPrimitiveType}}{{/multipartFormData}} - }{{/isArray}} - {{/formParams}}{{/vendorExtensions}} - {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} - localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} - {{/hasFormParams}}{{/vendorExtensions}} - {{#bodyParam}} - {{^consumes}} - localVarHeaderParameter['Content-Type'] = 'application/json'; - {{/consumes}} - {{#consumes.0}} - localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; - {{/consumes.0}} - - {{/bodyParam}} - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions,{{#hasFormParams}}{{#multipartFormData}} ...(localVarFormParams as any).getHeaders?.(),{{/multipartFormData}}{{/hasFormParams}} ...options.headers}; - {{#hasFormParams}} - localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; - {{/hasFormParams}} - {{#bodyParam}} - localVarRequestOptions.data = serializeDataIfNeeded({{paramName}}, localVarRequestOptions, configuration) - {{/bodyParam}} - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - {{/operation}} - } -}; - -/** - * {{classname}} - functional programming interface{{#description}} - * {{{.}}}{{/description}} - * @export - */ -export const {{classname}}Fp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration) - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - {{/operation}} - } -}; - -/** - * {{classname}} - factory interface{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = {{classname}}Fp(configuration) - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#useSingleRequestParameter}} - {{#allParams.0}} - * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. - {{/allParams.0}} - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - {{/useSingleRequestParameter}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - */ - {{#useSingleRequestParameter}} - {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: AxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { - return localVarFp.{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(axios, basePath)); - }, - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { - return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath)); - }, - {{/useSingleRequestParameter}} - {{/operation}} - }; -}; - -{{#withInterfaces}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export interface {{classname}}Interface { -{{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - * @memberof {{classname}}Interface - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; - -{{/operation}} -} - -{{/withInterfaces}} -{{#useSingleRequestParameter}} -{{#operation}} -{{#allParams.0}} -/** - * Request parameters for {{nickname}} operation in {{classname}}. - * @export - * @interface {{classname}}{{operationIdCamelCase}}Request - */ -export interface {{classname}}{{operationIdCamelCase}}Request { - {{#allParams}} - /** - * {{description}} - * @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> - * @memberof {{classname}}{{operationIdCamelCase}} - */ - readonly {{paramName}}{{^required}}?{{/required}}: {{{dataType}}} - {{^-last}} - - {{/-last}} - {{/allParams}} -} - -{{/allParams.0}} -{{/operation}} -{{/useSingleRequestParameter}} -/** - * {{classname}} - object-oriented interface{{#description}} - * {{{.}}}{{/description}} - * @export - * @class {{classname}} - * @extends {BaseAPI} - */ -{{#withInterfaces}} -export class {{classname}} extends BaseAPI implements {{classname}}Interface { -{{/withInterfaces}} -{{^withInterfaces}} -export class {{classname}} extends BaseAPI { -{{/withInterfaces}} - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#useSingleRequestParameter}} - {{#allParams.0}} - * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. - {{/allParams.0}} - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - {{/useSingleRequestParameter}} - * @param {*} [options] Override http request option.{{#isDeprecated}} - * @deprecated{{/isDeprecated}} - * @throws {RequiredError} - * @memberof {{classname}} - */ - {{#useSingleRequestParameter}} - public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: AxiosRequestConfig) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath)); - } - {{/useSingleRequestParameter}} - {{^useSingleRequestParameter}} - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: AxiosRequestConfig) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath)); - } - {{/useSingleRequestParameter}} - {{^-last}} - - {{/-last}} - {{/operation}} -} -{{/operations}} diff --git a/open-api/templates/typescript/apiInner.mustache.patch b/open-api/templates/typescript/apiInner.mustache.patch deleted file mode 100644 index 99963da620..0000000000 --- a/open-api/templates/typescript/apiInner.mustache.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- apiInner.mustache 2023-02-10 17:44:20.945845049 +0000 -+++ apiInner.mustache.patch 2023-02-10 17:46:28.669054112 +0000 -@@ -173,8 +173,9 @@ - {{^isArray}} - if ({{paramName}} !== undefined) { {{^multipartFormData}} - localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}} -- localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}} -- localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isPrimitiveType}}{{/multipartFormData}} -+ localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isEnum}} -+ localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isEnum}}{{^isEnum}} -+ localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isEnum}}{{/isPrimitiveType}}{{/multipartFormData}} - }{{/isArray}} - {{/formParams}}{{/vendorExtensions}} - {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}}