diff --git a/src/templates/core/axios/getHeaders.hbs b/src/templates/core/axios/getHeaders.hbs index 3643cd5b3..9997f8c6a 100644 --- a/src/templates/core/axios/getHeaders.hbs +++ b/src/templates/core/axios/getHeaders.hbs @@ -1,15 +1,13 @@ -export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise> => { +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise> => { const token = await resolve(options, config.TOKEN); const username = await resolve(options, config.USERNAME); const password = await resolve(options, config.PASSWORD); const additionalHeaders = await resolve(options, config.HEADERS); - const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {} const headers = Object.entries({ Accept: 'application/json', ...additionalHeaders, ...options.headers, - ...formHeaders, }) .filter(([_, value]) => isDefined(value)) .reduce((headers, [key, value]) => ({ diff --git a/src/templates/core/axios/request.hbs b/src/templates/core/axios/request.hbs index 6612f1614..9dc63155a 100644 --- a/src/templates/core/axios/request.hbs +++ b/src/templates/core/axios/request.hbs @@ -76,7 +76,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions, ax const url = getUrl(config, options); const formData = getFormData(options); const body = getRequestBody(options); - const headers = await getHeaders(config, options, formData); + const headers = await getHeaders(config, options); if (!onCancel.isCancelled) { const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient); diff --git a/src/templates/core/axios/sendRequest.hbs b/src/templates/core/axios/sendRequest.hbs index 51492bf3f..cd77ab21f 100644 --- a/src/templates/core/axios/sendRequest.hbs +++ b/src/templates/core/axios/sendRequest.hbs @@ -3,7 +3,7 @@ export const sendRequest = async ( options: ApiRequestOptions, url: string, body: any, - formData: FormData | undefined, + formData: Record | undefined, headers: Record, onCancel: OnCancel, axiosClient: AxiosInstance diff --git a/src/templates/core/functions/getFormData.hbs b/src/templates/core/functions/getFormData.hbs index b21930d39..e72bfc44f 100644 --- a/src/templates/core/functions/getFormData.hbs +++ b/src/templates/core/functions/getFormData.hbs @@ -1,26 +1,6 @@ -export const getFormData = (options: ApiRequestOptions): FormData | undefined => { +export const getFormData = (options: ApiRequestOptions): Record | undefined => { if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: any) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([_, value]) => isDefined(value)) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach(v => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; + return options.formData; } return undefined; }; diff --git a/src/templates/exportService.hbs b/src/templates/exportService.hbs index d6bccbbeb..abaead2e5 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/exportService.hbs @@ -13,7 +13,7 @@ import type { Observable } from 'rxjs'; {{/equals}} {{#if imports}} {{#each imports}} -import type { {{{this}}} } from '../models/{{{this}}}'; +{{#if this}}import type { {{{this}}} } from '../models/{{{this}}}';{{/if}} {{/each}} {{/if}} diff --git a/src/templates/partials/base.hbs b/src/templates/partials/base.hbs index 1799e7d2a..be396b2d0 100644 --- a/src/templates/partials/base.hbs +++ b/src/templates/partials/base.hbs @@ -5,5 +5,5 @@ {{~#equals @root.httpClient 'angular'}}Blob{{/equals~}} {{~#equals @root.httpClient 'node'}}Blob{{/equals~}} {{~else~}} -{{{base}}} +{{#if base}}{{{base}}}{{else}}unknown{{/if}} {{~/equals~}}