diff --git a/.changeset/hip-hats-invent.md b/.changeset/hip-hats-invent.md new file mode 100644 index 000000000..decd47754 --- /dev/null +++ b/.changeset/hip-hats-invent.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix: suffix illegal service names diff --git a/packages/openapi-ts/src/generate/services.ts b/packages/openapi-ts/src/generate/services.ts index 5c9f7c716..f478d6c54 100644 --- a/packages/openapi-ts/src/generate/services.ts +++ b/packages/openapi-ts/src/generate/services.ts @@ -13,6 +13,7 @@ import type { Model, Operation, OperationParameter, Service } from '../openApi'; import type { Client } from '../types/client'; import { getConfig, isStandaloneClient } from '../utils/config'; import { escapeComment, escapeName } from '../utils/escape'; +import { reservedWordsRegExp } from '../utils/reservedWords'; import { transformServiceName } from '../utils/transform'; import { setUniqueTypeName } from '../utils/type'; import { unique } from '../utils/unique'; @@ -381,14 +382,18 @@ const toRequestOptions = ( }); }; -const toOperationName = (operation: Operation) => { +const toOperationName = (operation: Operation, handleIllegal: boolean) => { const config = getConfig(); - if (!config.services.methodNameBuilder) { - return operation.name; + if (config.services.methodNameBuilder) { + return config.services.methodNameBuilder(operation); } - return config.services.methodNameBuilder(operation); + if (handleIllegal && operation.name.match(reservedWordsRegExp)) { + return `${operation.name}_`; + } + + return operation.name; }; const toOperationStatements = ( @@ -544,7 +549,7 @@ const processService = ( const statement = compiler.export.const({ comment: toOperationComment(operation), expression, - name: toOperationName(operation), + name: toOperationName(operation, true), }); onNode(statement); }); @@ -556,7 +561,7 @@ const processService = ( accessLevel: 'public', comment: toOperationComment(operation), isStatic: config.name === undefined && config.client !== 'angular', - name: toOperationName(operation), + name: toOperationName(operation, false), parameters: toOperationParamType(client, operation), returnType: isStandalone ? undefined diff --git a/packages/openapi-ts/src/openApi/common/interfaces/client.ts b/packages/openapi-ts/src/openApi/common/interfaces/client.ts index cc4ba598c..e3190c3a4 100644 --- a/packages/openapi-ts/src/openApi/common/interfaces/client.ts +++ b/packages/openapi-ts/src/openApi/common/interfaces/client.ts @@ -53,9 +53,6 @@ export interface Operation extends OperationParameters { */ id: string | null; method: Method; - /** - * Method name. Methods contain the request logic. - */ name: string; path: string; responseHeader: string | null; diff --git a/packages/openapi-ts/src/openApi/common/parser/type.ts b/packages/openapi-ts/src/openApi/common/parser/type.ts index df250f8dd..430cd60db 100644 --- a/packages/openapi-ts/src/openApi/common/parser/type.ts +++ b/packages/openapi-ts/src/openApi/common/parser/type.ts @@ -1,10 +1,10 @@ import camelcase from 'camelcase'; import { getConfig, isStandaloneClient } from '../../../utils/config'; +import { reservedWordsRegExp } from '../../../utils/reservedWords'; import { transformTypeName } from '../../../utils/transform'; import { isDefinitionTypeNullable } from '../../v3/parser/inferType'; import type { Type } from '../interfaces/Type'; -import { reservedWords } from './reservedWords'; import { ensureValidTypeScriptJavaScriptIdentifier, sanitizeOperationParameterName, @@ -166,5 +166,5 @@ export const transformTypeKeyName = (value: string): string => { } const clean = sanitizeOperationParameterName(value).trim(); - return camelcase(clean).replace(reservedWords, '_$1'); + return camelcase(clean).replace(reservedWordsRegExp, '_$1'); }; diff --git a/packages/openapi-ts/src/openApi/v2/parser/getModels.ts b/packages/openapi-ts/src/openApi/v2/parser/getModels.ts index 29f024578..6c406ef34 100644 --- a/packages/openapi-ts/src/openApi/v2/parser/getModels.ts +++ b/packages/openapi-ts/src/openApi/v2/parser/getModels.ts @@ -1,5 +1,5 @@ import type { Client } from '../../../types/client'; -import { reservedWords } from '../../common/parser/reservedWords'; +import { reservedWordsRegExp } from '../../../utils/reservedWords'; import { getType } from '../../common/parser/type'; import type { OpenApi } from '../interfaces/OpenApi'; import { getModel } from './getModel'; @@ -13,7 +13,7 @@ export const getModels = ( Object.entries(openApi.definitions ?? {}).forEach( ([definitionName, definition]) => { const definitionType = getType({ type: definitionName }); - const name = definitionType.base.replace(reservedWords, '_$1'); + const name = definitionType.base.replace(reservedWordsRegExp, '_$1'); const meta = { $ref: `#/definitions/${definitionName}`, name, diff --git a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.spec.ts b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.spec.ts index f37e3ebef..de5c5a7f7 100644 --- a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.spec.ts +++ b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest'; import type { Config } from '../../../../types/config'; -import { reservedWords } from '../../../common/parser/reservedWords'; +import { reservedWordsRegExp } from '../../../../utils/reservedWords'; import { getType } from '../../../common/parser/type'; import { getModel } from '../getModel'; @@ -96,7 +96,7 @@ describe('getModel', () => { isDefinition: true, meta: { $ref: '', - name: definitionType.base.replace(reservedWords, '_$1'), + name: definitionType.base.replace(reservedWordsRegExp, '_$1'), }, openApi, types: {}, @@ -112,7 +112,7 @@ describe('getModel', () => { isDefinition: true, meta: { $ref: '', - name: definitionType.base.replace(reservedWords, '_$1'), + name: definitionType.base.replace(reservedWordsRegExp, '_$1'), }, openApi, types: {}, diff --git a/packages/openapi-ts/src/openApi/v3/parser/getModels.ts b/packages/openapi-ts/src/openApi/v3/parser/getModels.ts index 86ed58e68..3bc52d767 100644 --- a/packages/openapi-ts/src/openApi/v3/parser/getModels.ts +++ b/packages/openapi-ts/src/openApi/v3/parser/getModels.ts @@ -1,6 +1,6 @@ import type { Client } from '../../../types/client'; import { getConfig } from '../../../utils/config'; -import { reservedWords } from '../../common/parser/reservedWords'; +import { reservedWordsRegExp } from '../../../utils/reservedWords'; import { getType } from '../../common/parser/type'; import type { OpenApi } from '../interfaces/OpenApi'; import { getModel } from './getModel'; @@ -24,7 +24,7 @@ export const getModels = ( Object.entries(openApi.components.schemas ?? {}).forEach( ([definitionName, definition]) => { const definitionType = getType({ type: definitionName }); - const name = definitionType.base.replace(reservedWords, '_$1'); + const name = definitionType.base.replace(reservedWordsRegExp, '_$1'); const meta = { $ref: `#/components/schemas/${definitionName}`, name, @@ -66,7 +66,7 @@ export const getModels = ( * Note: there's a related code to this workaround in `getType()` * method that needs to be cleaned up when this is addressed. */ - const name = `Parameter${definitionType.base.replace(reservedWords, '_$1')}`; + const name = `Parameter${definitionType.base.replace(reservedWordsRegExp, '_$1')}`; const meta = { $ref: `#/components/parameters/${definitionName}`, name, diff --git a/packages/openapi-ts/src/utils/escape.ts b/packages/openapi-ts/src/utils/escape.ts index c7153b0ea..52491962a 100644 --- a/packages/openapi-ts/src/utils/escape.ts +++ b/packages/openapi-ts/src/utils/escape.ts @@ -4,12 +4,12 @@ import { EOL } from 'os'; * Javascript identifier regexp pattern retrieved from * {@link} https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers */ -const validTypescriptIdentifierRegex = +const validTypescriptIdentifierRegExp = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u; export const escapeName = (value: string): string => { if (value || value === '') { - const validName = validTypescriptIdentifierRegex.test(value); + const validName = validTypescriptIdentifierRegExp.test(value); if (!validName) { return `'${value}'`; } diff --git a/packages/openapi-ts/src/openApi/common/parser/reservedWords.ts b/packages/openapi-ts/src/utils/reservedWords.ts similarity index 89% rename from packages/openapi-ts/src/openApi/common/parser/reservedWords.ts rename to packages/openapi-ts/src/utils/reservedWords.ts index d94f14cb2..e26e6c906 100644 --- a/packages/openapi-ts/src/openApi/common/parser/reservedWords.ts +++ b/packages/openapi-ts/src/utils/reservedWords.ts @@ -1,2 +1,2 @@ -export const reservedWords = +export const reservedWordsRegExp = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g; 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 e956c741c..64841a9cf 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,13 +3,13 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { PostServiceWithEmptyTagData, PostServiceWithEmptyTagResponse3, 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 } from './types.gen'; export class DefaultService { /** * @throws ApiError */ - public static serviceWithEmptyTag(): CancelablePromise { + public static export(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -23,7 +23,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public static import(data: ImportData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 28364407c..1abe591c8 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 @@ -997,11 +997,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1426,7 +1426,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { + public export(): Observable { return __request(OpenAPI, this.http, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -30,7 +30,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): Observable { + public import(data: ImportData): Observable { return __request(OpenAPI, this.http, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 22066ae2b..99fea7d67 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 @@ -874,11 +874,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1303,7 +1303,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { + public static export(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -23,7 +23,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public static import(data: ImportData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 28364407c..1abe591c8 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 @@ -997,11 +997,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1426,7 +1426,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { + public export(): CancelablePromise { return this.httpRequest.request({ method: 'GET', url: '/api/v{api-version}/no-tag' @@ -24,7 +24,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public import(data: ImportData): CancelablePromise { return this.httpRequest.request({ method: 'POST', url: '/api/v{api-version}/no-tag', 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 30ea3f5db..3b0652a91 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 @@ -874,11 +874,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1303,7 +1303,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { + public static export(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -23,7 +23,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public static import(data: ImportData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 774c2066a..b4755defb 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 @@ -953,11 +953,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1382,7 +1382,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { return (options?.client ?? client).get({ +export const export_ = (options?: Options) => { return (options?.client ?? client).get({ ...options, url: '/api/v{api-version}/no-tag' }); }; -export const postServiceWithEmptyTag = (options: Options) => { return (options?.client ?? client).post({ +export const import_ = (options: Options) => { return (options?.client ?? client).post({ ...options, url: '/api/v{api-version}/no-tag' }); }; 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 cc29c9fdc..0beda34f0 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 @@ -997,13 +997,13 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { body: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; -export type PostServiceWithEmptyTagError = unknown; +export type ImportError = unknown; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1491,7 +1491,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Error = unknown; export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { - req: PostServiceWithEmptyTagData; + req: ImportData; res: { /** * Success 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 aeadf8755..b8cd7ff56 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,14 +1,14 @@ // This file is auto-generated by @hey-api/openapi-ts import { client, type Options, formDataBodySerializer } from '@hey-api/client-fetch'; -import type { PostServiceWithEmptyTagData, PostServiceWithEmptyTagError, PostServiceWithEmptyTagResponse3, 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 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'; -export const serviceWithEmptyTag = (options?: Options) => { return (options?.client ?? client).get({ +export const export_ = (options?: Options) => { return (options?.client ?? client).get({ ...options, url: '/api/v{api-version}/no-tag' }); }; -export const postServiceWithEmptyTag = (options: Options) => { return (options?.client ?? client).post({ +export const import_ = (options: Options) => { return (options?.client ?? client).post({ ...options, url: '/api/v{api-version}/no-tag' }); }; 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 cc29c9fdc..0beda34f0 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 @@ -997,13 +997,13 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { body: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; -export type PostServiceWithEmptyTagError = unknown; +export type ImportError = unknown; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1491,7 +1491,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Error = unknown; export type $OpenApiTs = { '/api/v{api-version}/no-tag': { post: { - req: PostServiceWithEmptyTagData; + req: ImportData; res: { /** * Success 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 e956c741c..64841a9cf 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,13 +3,13 @@ import type { CancelablePromise } from './core/CancelablePromise'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; -import type { PostServiceWithEmptyTagData, PostServiceWithEmptyTagResponse3, 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 } from './types.gen'; export class DefaultService { /** * @throws ApiError */ - public static serviceWithEmptyTag(): CancelablePromise { + public static export(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -23,7 +23,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public static import(data: ImportData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 28364407c..1abe591c8 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 @@ -997,11 +997,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1426,7 +1426,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse = ModelFromZendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = ModelFromZendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = ModelFromZendesk; @@ -445,7 +445,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array => { return __request(OpenAPI, { +export const export_ = (): CancelablePromise => { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' }); }; @@ -20,7 +20,7 @@ export const serviceWithEmptyTag = (): CancelablePromise => { return __req * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ -export const postServiceWithEmptyTag = (data: PostServiceWithEmptyTagData): CancelablePromise => { return __request(OpenAPI, { +export const import_ = (data: ImportData): CancelablePromise => { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', body: data.requestBody, 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 40ce295c2..a8772d59f 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 @@ -997,11 +997,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1426,7 +1426,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array { + public static export(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/v{api-version}/no-tag' @@ -23,7 +23,7 @@ export class DefaultService { * @returns ModelWithReadOnlyAndWriteOnly Default success response * @throws ApiError */ - public static postServiceWithEmptyTag(data: PostServiceWithEmptyTagData): CancelablePromise { + public static import(data: ImportData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/api/v{api-version}/no-tag', 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 28364407c..1abe591c8 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 @@ -997,11 +997,11 @@ export type ParameterSimpleParameter = string; */ export type Parameterx_Foo_Bar = ModelWithString; -export type PostServiceWithEmptyTagData = { +export type ImportData = { requestBody: ModelWithReadOnlyAndWriteOnly | ModelWithArrayReadOnlyAndWriteOnly; }; -export type PostServiceWithEmptyTagResponse3 = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; +export type ImportResponse = Model_From_Zendesk | ModelWithReadOnlyAndWriteOnly; export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; @@ -1426,7 +1426,7 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Response = Array