From f6be83859d022ca9725382f8bf990618411ef1af Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 17 Jul 2024 15:52:14 +0100 Subject: [PATCH] fix: handle application/x-www-form-urlencoded content in request body --- .changeset/smooth-dingos-unite.md | 6 +++ packages/client-core/src/types.ts | 2 +- packages/client-fetch/src/index.ts | 4 -- packages/client-fetch/src/node/index.ts | 6 ++- packages/client-fetch/src/utils.ts | 51 +++++++++++++++---- packages/openapi-ts/src/generate/services.ts | 35 ++++++++++--- .../src/templates/core/ApiRequestOptions.hbs | 21 +++++--- .../v2/core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3/core/ApiRequestOptions.ts.snap | 21 +++++--- .../test/generated/v3/services.gen.ts.snap | 17 ++++++- .../test/generated/v3/types.gen.ts.snap | 7 +++ .../v3_angular/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_angular/services.gen.ts.snap | 17 ++++++- .../generated/v3_angular/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_axios/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_axios/services.gen.ts.snap | 17 ++++++- .../test/generated/v3_axios/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_client/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_client/services.gen.ts.snap | 17 ++++++- .../generated/v3_client/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../test/generated/v3_date/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_enums_typescript/services.gen.ts.snap | 17 ++++++- .../v3_enums_typescript/types.gen.ts.snap | 7 +++ .../services.gen.ts.snap | 16 +++++- .../v3_hey-api_client-axios/types.gen.ts.snap | 7 +++ .../services.gen.ts.snap | 16 +++++- .../v3_hey-api_client-fetch/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_node/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_node/services.gen.ts.snap | 17 ++++++- .../test/generated/v3_node/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_options/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_pascalcase/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- .../v3_tree_shakeable/services.gen.ts.snap | 15 +++++- .../v3_tree_shakeable/types.gen.ts.snap | 7 +++ .../test/generated/v3_types/types.gen.ts.snap | 7 +++ .../v3_types_no_tree/types.gen.ts.snap | 6 ++- .../v3_xhr/core/ApiRequestOptions.ts.snap | 21 +++++--- .../generated/v3_xhr/services.gen.ts.snap | 17 ++++++- .../test/generated/v3_xhr/types.gen.ts.snap | 7 +++ .../core/ApiRequestOptions.ts.snap | 21 +++++--- packages/openapi-ts/test/sample.cjs | 4 +- packages/openapi-ts/test/spec/v3.json | 15 ++++++ 49 files changed, 584 insertions(+), 159 deletions(-) create mode 100644 .changeset/smooth-dingos-unite.md diff --git a/.changeset/smooth-dingos-unite.md b/.changeset/smooth-dingos-unite.md new file mode 100644 index 000000000..c0302b6b4 --- /dev/null +++ b/.changeset/smooth-dingos-unite.md @@ -0,0 +1,6 @@ +--- +'@hey-api/client-fetch': patch +'@hey-api/openapi-ts': patch +--- + +fix: handle application/x-www-form-urlencoded content in request body diff --git a/packages/client-core/src/types.ts b/packages/client-core/src/types.ts index ad0d657f5..d3b14321e 100644 --- a/packages/client-core/src/types.ts +++ b/packages/client-core/src/types.ts @@ -10,7 +10,7 @@ export type ApiRequestOptions = { readonly body?: any; readonly cookies?: Record; readonly errors?: Record; - readonly formData?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; readonly mediaType?: string; readonly method: diff --git a/packages/client-fetch/src/index.ts b/packages/client-fetch/src/index.ts index 476670929..4db32ef16 100644 --- a/packages/client-fetch/src/index.ts +++ b/packages/client-fetch/src/index.ts @@ -69,10 +69,6 @@ export const createClient = (config: Config): Client => { redirect: 'follow', ...opts, }; - // remove Content-Type if serialized body is FormData; browser will correctly set Content-Type and boundary expression - if (requestInit.body instanceof FormData) { - requestInit.headers.delete('Content-Type'); - } let request = new Request(url, requestInit); diff --git a/packages/client-fetch/src/node/index.ts b/packages/client-fetch/src/node/index.ts index 497c09343..1a4585eeb 100644 --- a/packages/client-fetch/src/node/index.ts +++ b/packages/client-fetch/src/node/index.ts @@ -1,3 +1,7 @@ export { client, createClient } from '../'; export type { Client, Options, RequestResult } from '../types'; -export { formDataBodySerializer, jsonBodySerializer } from '../utils'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../utils'; diff --git a/packages/client-fetch/src/utils.ts b/packages/client-fetch/src/utils.ts index bf6a1dc4a..b7f026ce0 100644 --- a/packages/client-fetch/src/utils.ts +++ b/packages/client-fetch/src/utils.ts @@ -460,15 +460,11 @@ export const createInterceptors = () => ({ response: new Interceptors>(), }); -const serializeFormDataPair = ( - formData: FormData, - key: string, - value: unknown, -) => { +const serializeFormDataPair = (data: FormData, key: string, value: unknown) => { if (typeof value === 'string' || value instanceof Blob) { - formData.append(key, value); + data.append(key, value); } else { - formData.append(key, JSON.stringify(value)); + data.append(key, JSON.stringify(value)); } }; @@ -476,20 +472,20 @@ export const formDataBodySerializer = { bodySerializer: | Array>>( body: T, ) => { - const formData = new FormData(); + const data = new FormData(); Object.entries(body).forEach(([key, value]) => { if (value === undefined || value === null) { return; } if (Array.isArray(value)) { - value.forEach((v) => serializeFormDataPair(formData, key, v)); + value.forEach((v) => serializeFormDataPair(data, key, v)); } else { - serializeFormDataPair(formData, key, value); + serializeFormDataPair(data, key, value); } }); - return formData; + return data; }, }; @@ -497,6 +493,39 @@ export const jsonBodySerializer = { bodySerializer: (body: T) => JSON.stringify(body), }; +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +) => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ) => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data; + }, +}; + const defaultQuerySerializer = createQuerySerializer({ allowReserved: false, array: { diff --git a/packages/openapi-ts/src/generate/services.ts b/packages/openapi-ts/src/generate/services.ts index ce8377882..077e55136 100644 --- a/packages/openapi-ts/src/generate/services.ts +++ b/packages/openapi-ts/src/generate/services.ts @@ -247,14 +247,33 @@ const toRequestOptions = ( .map((parameter) => parameter.mediaType) .filter(Boolean) .filter(unique); - if (contents.length === 1 && contents[0] === 'multipart/form-data') { - obj = [ - ...obj, - { - spread: 'formDataBodySerializer', - }, - ]; - onClientImport?.('formDataBodySerializer'); + if (contents.length === 1) { + if (contents[0] === 'multipart/form-data') { + obj = [ + ...obj, + { + spread: 'formDataBodySerializer', + }, + // no need for Content-Type header, browser will set it automatically + ]; + onClientImport?.('formDataBodySerializer'); + } + + if (contents[0] === 'application/x-www-form-urlencoded') { + obj = [ + ...obj, + { + spread: 'urlSearchParamsBodySerializer', + }, + { + key: 'headers', + value: { + 'Content-Type': contents[0], + }, + }, + ]; + onClientImport?.('urlSearchParamsBodySerializer'); + } } // TODO: set parseAs to skip inference if every result has the same diff --git a/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs b/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs index 2c83c55dd..807fc46ef 100644 --- a/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs +++ b/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/services.gen.ts.snap index 44c096b6b..3d60b776f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { /** @@ -859,4 +859,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public static putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap index 46c9a0b2a..45c59d854 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/types.gen.ts.snap @@ -1428,6 +1428,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1784,5 +1788,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/services.gen.ts.snap index e3198fd30..eca1595c6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/services.gen.ts.snap @@ -5,7 +5,7 @@ import { HttpClient } from '@angular/common/http'; import type { Observable } from 'rxjs'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; @Injectable({ providedIn: 'root' @@ -976,4 +976,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): Observable { + return __request(OpenAPI, this.http, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap index e215e1bc0..b65f39df0 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap @@ -1305,6 +1305,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1661,5 +1665,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/services.gen.ts.snap index 44c096b6b..3d60b776f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { /** @@ -859,4 +859,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public static putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap index 46c9a0b2a..45c59d854 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap @@ -1428,6 +1428,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1784,5 +1788,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/services.gen.ts.snap index 1c5aa3829..cf286eef7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/services.gen.ts.snap @@ -2,7 +2,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import type { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { constructor(public readonly httpRequest: BaseHttpRequest) { } @@ -904,4 +904,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap index 39bc9a6a5..78da483b9 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap @@ -1305,6 +1305,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1661,5 +1665,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap index 454bd7396..8e83c64b9 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap @@ -441,6 +441,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -797,5 +801,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/services.gen.ts.snap index 44c096b6b..3d60b776f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { /** @@ -859,4 +859,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public static putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap index dd16dce6a..ce3d0be0e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap @@ -1384,6 +1384,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1740,5 +1744,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/services.gen.ts.snap index 86b6521a8..817af0d64 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/services.gen.ts.snap @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { client, type Options, formDataBodySerializer } from '@hey-api/client-axios'; -import type { ImportData, ImportError, ImportResponse, ApiVversionOdataControllerCountError, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseError, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseError, CallWithResponseAndNoContentResponseResponse, DummyAError, DummyAResponse, DummyBError, DummyBResponse, CallWithResponseError, CallWithResponseResponse, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesError, TypesResponse, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, FileResponseError, FileResponseResponse, ComplexTypesData, ComplexTypesError, ComplexTypesResponse, MultipartRequestData, MultipartResponseError, MultipartResponseResponse, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import { client, type Options, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/client-axios'; +import type { ImportData, ImportError, ImportResponse, ApiVversionOdataControllerCountError, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseError, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseError, CallWithResponseAndNoContentResponseResponse, DummyAError, DummyAResponse, DummyBError, DummyBResponse, CallWithResponseError, CallWithResponseResponse, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesError, TypesResponse, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, FileResponseError, FileResponseResponse, ComplexTypesData, ComplexTypesError, ComplexTypesResponse, MultipartRequestData, MultipartResponseError, MultipartResponseResponse, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export const export_ = (options?: Options) => { return (options?.client ?? client).get({ ...options, @@ -226,4 +226,16 @@ export const testErrorCode = (options: Options) => { return ( export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { return (options?.client ?? client).post({ ...options, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串' +}); }; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { return (options?.client ?? client).put({ + ...options, + ...urlSearchParamsBodySerializer, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串' }); }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap index 687c785ee..1a058b0aa 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap @@ -1493,6 +1493,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/services.gen.ts.snap index b8cd7ff56..928e5876d 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/services.gen.ts.snap @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { client, type Options, formDataBodySerializer } from '@hey-api/client-fetch'; -import type { ImportData, ImportError, ImportResponse, ApiVversionOdataControllerCountError, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseError, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseError, CallWithResponseAndNoContentResponseResponse, DummyAError, DummyAResponse, DummyBError, DummyBResponse, CallWithResponseError, CallWithResponseResponse, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesError, TypesResponse, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, FileResponseError, FileResponseResponse, ComplexTypesData, ComplexTypesError, ComplexTypesResponse, MultipartRequestData, MultipartResponseError, MultipartResponseResponse, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import { client, type Options, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/client-fetch'; +import type { ImportData, ImportError, ImportResponse, ApiVversionOdataControllerCountError, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseError, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseError, CallWithResponseAndNoContentResponseResponse, DummyAError, DummyAResponse, DummyBError, DummyBResponse, CallWithResponseError, CallWithResponseResponse, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesError, TypesResponse, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, FileResponseError, FileResponseResponse, ComplexTypesData, ComplexTypesError, ComplexTypesResponse, MultipartRequestData, MultipartResponseError, MultipartResponseResponse, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export const export_ = (options?: Options) => { return (options?.client ?? client).get({ ...options, @@ -226,4 +226,16 @@ export const testErrorCode = (options: Options) => { return ( export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { return (options?.client ?? client).post({ ...options, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串' +}); }; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { return (options?.client ?? client).put({ + ...options, + ...urlSearchParamsBodySerializer, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串' }); }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap index 687c785ee..1a058b0aa 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap @@ -1493,6 +1493,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/services.gen.ts.snap index 44c096b6b..3d60b776f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { /** @@ -859,4 +859,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public static putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap index 46c9a0b2a..45c59d854 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap @@ -1428,6 +1428,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1784,5 +1788,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_pascalcase/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_pascalcase/types.gen.ts.snap index 88ff7cc9e..6889a0b22 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_pascalcase/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_pascalcase/types.gen.ts.snap @@ -442,6 +442,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -798,5 +802,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/services.gen.ts.snap index 3a7637ad9..b918818ab 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, DummyAResponse, DummyBResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartRequestData, MultipartResponseResponse, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, DummyAResponse, DummyBResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartRequestData, MultipartResponseResponse, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; /** * @throws ApiError @@ -657,4 +657,17 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (data: NonAsciiæøåÆøÅ query: { 'nonAsciiParamæøåÆØÅöôêÊ': data.nonAsciiParamæøåÆøÅöôêÊ } +}); }; + +/** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ +export const putWithFormUrlEncoded = (data: PutWithFormUrlEncodedData): CancelablePromise => { return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' }); }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap index 1dcf807e0..246d37b5a 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap @@ -1428,6 +1428,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1784,5 +1788,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap index eac5dda0e..5984a780f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap @@ -1305,6 +1305,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1661,5 +1665,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap index 6b6dcc609..d7e44dbfe 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap @@ -1303,4 +1303,8 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { nonAsciiParamæøåÆøÅöôêÊ: number; }; -export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; \ No newline at end of file +export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; + +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/services.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/services.gen.ts.snap index 44c096b6b..3d60b776f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/services.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/services.gen.ts.snap @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from './types.gen'; +import type { ImportData, ImportResponse, ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiRequestBodyData, PostApiFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse, MultipartRequestData, MultipartResponseResponse, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from './types.gen'; export class DefaultService { /** @@ -859,4 +859,19 @@ export class NonAsciiÆøåÆøÅöôêÊService { }); } + /** + * Login User + * @param data The data for the request. + * @param data.formData + * @throws ApiError + */ + public static putWithFormUrlEncoded(data: PutWithFormUrlEncodedData): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + formData: data.formData, + mediaType: 'application/x-www-form-urlencoded' + }); + } + } \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap index 46c9a0b2a..45c59d854 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap @@ -1428,6 +1428,10 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = { export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; +export type PutWithFormUrlEncodedData = { + formData: ArrayWithStrings; +}; + export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { @@ -1784,5 +1788,8 @@ export type $OpenApiTs = { 200: Array; }; }; + put: { + req: PutWithFormUrlEncodedData; + }; }; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap index 1758d98c4..f7b8b5641 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap @@ -1,14 +1,21 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; + readonly body?: any; readonly cookies?: Record; + readonly errors?: Record; + readonly formData?: Record | Record[]; readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; readonly mediaType?: string; + readonly method: + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT'; + readonly path?: Record; + readonly query?: Record; readonly responseHeader?: string; readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; + readonly url: string; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/sample.cjs b/packages/openapi-ts/test/sample.cjs index c169c6af8..fe1d36325 100644 --- a/packages/openapi-ts/test/sample.cjs +++ b/packages/openapi-ts/test/sample.cjs @@ -21,8 +21,8 @@ const main = async () => { // export: false, }, services: { - asClass: true, - filter: '^\\w+ /api/v{api-version}/simple$', + // asClass: true, + filter: '^PUT /api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串$', // export: false, // name: '^Parameters', }, diff --git a/packages/openapi-ts/test/spec/v3.json b/packages/openapi-ts/test/spec/v3.json index b6cab0a8c..77e4c8a4f 100644 --- a/packages/openapi-ts/test/spec/v3.json +++ b/packages/openapi-ts/test/spec/v3.json @@ -1626,6 +1626,21 @@ } } } + }, + "put": { + "tags": ["Non-Ascii-æøåÆØÅöôêÊ"], + "summary": "Login User", + "operationId": "putWithFormUrlEncoded", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/ArrayWithStrings" + } + } + }, + "required": true + } } } },