diff --git a/packages/openapi-ts-tests/main/package.json b/packages/openapi-ts-tests/main/package.json index 091b5064b..d830ff8b6 100644 --- a/packages/openapi-ts-tests/main/package.json +++ b/packages/openapi-ts-tests/main/package.json @@ -30,6 +30,8 @@ "@hey-api/custom-client": "workspace:*", "@hey-api/openapi-ts": "workspace:*", "@pinia/colada": "0.17.2", + "@nestjs/common": "11.1.6", + "@nestjs/core": "11.1.6", "@tanstack/angular-query-experimental": "5.73.3", "@tanstack/react-query": "5.73.3", "@tanstack/solid-query": "5.73.3", diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api-client.service.gen.ts new file mode 100644 index 000000000..ddc0e43a0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class ApiClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const API_CLIENT_CONFIG = 'API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api.module.gen.ts new file mode 100644 index 000000000..ddd6e339c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/api.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { ApiClient } from './api-client.service.gen'; + +import { ApiDefaultService } from './services/api-default.service.gen'; + +import { ApiSimpleService } from './services/api-simple.service.gen'; + +import { ApiParametersService } from './services/api-parameters.service.gen'; + +import { ApiDescriptionsService } from './services/api-descriptions.service.gen'; + +import { ApiDeprecatedService } from './services/api-deprecated.service.gen'; + +import { ApiRequestBodyService } from './services/api-requestbody.service.gen'; + +import { ApiFormDataService } from './services/api-formdata.service.gen'; + +import { ApiDefaultsService } from './services/api-defaults.service.gen'; + +import { ApiDuplicateService } from './services/api-duplicate.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiResponseService } from './services/api-response.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiMultipleTags1Service } from './services/api-multipletags1.service.gen'; + +import { ApiMultipleTags2Service } from './services/api-multipletags2.service.gen'; + +import { ApiMultipleTags3Service } from './services/api-multipletags3.service.gen'; + +import { ApiCollectionFormatService } from './services/api-collectionformat.service.gen'; + +import { ApiTypesService } from './services/api-types.service.gen'; + +import { ApiUploadService } from './services/api-upload.service.gen'; + +import { ApiFileResponseService } from './services/api-fileresponse.service.gen'; + +import { ApiComplexService } from './services/api-complex.service.gen'; + +import { ApiMultipartService } from './services/api-multipart.service.gen'; + +import { ApiHeaderService } from './services/api-header.service.gen'; + +import { ApiErrorService } from './services/api-error.service.gen'; + +import { ApiNonAsciiÆøåÆøÅöôêÊService } from './services/api-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class ApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: ApiModule, + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useValue: config + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: ApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-collectionformat.service.gen.ts new file mode 100644 index 000000000..5546e7e60 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class ApiCollectionFormatService { + constructor(private readonly client: ApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-complex.service.gen.ts new file mode 100644 index 000000000..ab9d15b3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class ApiComplexService { + constructor(private readonly client: ApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-default.service.gen.ts new file mode 100644 index 000000000..7d4e4716c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class ApiDefaultService { + constructor(private readonly client: ApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-defaults.service.gen.ts new file mode 100644 index 000000000..f0e60983c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class ApiDefaultsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-deprecated.service.gen.ts new file mode 100644 index 000000000..0c30727d8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class ApiDeprecatedService { + constructor(private readonly client: ApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-descriptions.service.gen.ts new file mode 100644 index 000000000..6a8839bf8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class ApiDescriptionsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-duplicate.service.gen.ts new file mode 100644 index 000000000..3ae1e3458 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class ApiDuplicateService { + constructor(private readonly client: ApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-error.service.gen.ts new file mode 100644 index 000000000..2435ca78c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class ApiErrorService { + constructor(private readonly client: ApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-fileresponse.service.gen.ts new file mode 100644 index 000000000..30977163e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiFileResponseService { + constructor(private readonly client: ApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-formdata.service.gen.ts new file mode 100644 index 000000000..7f0627712 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class ApiFormDataService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-header.service.gen.ts new file mode 100644 index 000000000..f3404da09 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class ApiHeaderService { + constructor(private readonly client: ApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipart.service.gen.ts new file mode 100644 index 000000000..69326948d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class ApiMultipartService { + constructor(private readonly client: ApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags1.service.gen.ts new file mode 100644 index 000000000..903a1497b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags1Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags2.service.gen.ts new file mode 100644 index 000000000..c0f73ad6c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags2Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags3.service.gen.ts new file mode 100644 index 000000000..f56684cfd --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags3Service { + constructor(private readonly client: ApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-nocontent.service.gen.ts new file mode 100644 index 000000000..9c51f8923 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiNoContentService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..4e288b7dc --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class ApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: ApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-parameters.service.gen.ts new file mode 100644 index 000000000..8bf767f3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class ApiParametersService { + constructor(private readonly client: ApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-requestbody.service.gen.ts new file mode 100644 index 000000000..7d3c1be6e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class ApiRequestBodyService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-response.service.gen.ts new file mode 100644 index 000000000..426e47705 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class ApiResponseService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-simple.service.gen.ts new file mode 100644 index 000000000..3d9ed4cc8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class ApiSimpleService { + constructor(private readonly client: ApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-types.service.gen.ts new file mode 100644 index 000000000..d993617ac --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class ApiTypesService { + constructor(private readonly client: ApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-upload.service.gen.ts new file mode 100644 index 000000000..b967a2e05 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/services/api-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class ApiUploadService { + constructor(private readonly client: ApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/sdk.gen.ts new file mode 100644 index 000000000..e79f50b13 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/bundled/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-collectionformat.service.gen.ts new file mode 100644 index 000000000..f6fba2c7f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class TestApiCollectionFormatService { + constructor(private readonly client: TestApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-complex.service.gen.ts new file mode 100644 index 000000000..ff6dccce0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class TestApiComplexService { + constructor(private readonly client: TestApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-default.service.gen.ts new file mode 100644 index 000000000..812b542c5 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class TestApiDefaultService { + constructor(private readonly client: TestApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-defaults.service.gen.ts new file mode 100644 index 000000000..40c92f4ee --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class TestApiDefaultsService { + constructor(private readonly client: TestApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-deprecated.service.gen.ts new file mode 100644 index 000000000..29e8c3693 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class TestApiDeprecatedService { + constructor(private readonly client: TestApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-descriptions.service.gen.ts new file mode 100644 index 000000000..0a6d11dae --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class TestApiDescriptionsService { + constructor(private readonly client: TestApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-duplicate.service.gen.ts new file mode 100644 index 000000000..27fd3f172 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class TestApiDuplicateService { + constructor(private readonly client: TestApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-error.service.gen.ts new file mode 100644 index 000000000..e0fe3b99b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class TestApiErrorService { + constructor(private readonly client: TestApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-fileresponse.service.gen.ts new file mode 100644 index 000000000..e82da9db3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class TestApiFileResponseService { + constructor(private readonly client: TestApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-formdata.service.gen.ts new file mode 100644 index 000000000..da4ab39c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class TestApiFormDataService { + constructor(private readonly client: TestApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-header.service.gen.ts new file mode 100644 index 000000000..65a33c740 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class TestApiHeaderService { + constructor(private readonly client: TestApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipart.service.gen.ts new file mode 100644 index 000000000..674bb4960 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class TestApiMultipartService { + constructor(private readonly client: TestApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags1.service.gen.ts new file mode 100644 index 000000000..0cb597ef0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class TestApiMultipleTags1Service { + constructor(private readonly client: TestApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags2.service.gen.ts new file mode 100644 index 000000000..18ca272d7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class TestApiMultipleTags2Service { + constructor(private readonly client: TestApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags3.service.gen.ts new file mode 100644 index 000000000..2f5ac3b1c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class TestApiMultipleTags3Service { + constructor(private readonly client: TestApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-nocontent.service.gen.ts new file mode 100644 index 000000000..a9b7d998c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class TestApiNoContentService { + constructor(private readonly client: TestApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..f68bd64c6 --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class TestApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: TestApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-parameters.service.gen.ts new file mode 100644 index 000000000..271f4c648 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class TestApiParametersService { + constructor(private readonly client: TestApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-requestbody.service.gen.ts new file mode 100644 index 000000000..1fb380cf7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class TestApiRequestBodyService { + constructor(private readonly client: TestApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-response.service.gen.ts new file mode 100644 index 000000000..ef85d3a10 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class TestApiResponseService { + constructor(private readonly client: TestApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-simple.service.gen.ts new file mode 100644 index 000000000..ad225ef94 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class TestApiSimpleService { + constructor(private readonly client: TestApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-types.service.gen.ts new file mode 100644 index 000000000..faa93f1c4 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class TestApiTypesService { + constructor(private readonly client: TestApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-upload.service.gen.ts new file mode 100644 index 000000000..a0226af2a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/services/testapi-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { TestApiClient } from '../testapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class TestApiUploadService { + constructor(private readonly client: TestApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi-client.service.gen.ts new file mode 100644 index 000000000..472edc476 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class MyHttpClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('TEST_API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const TEST_API_CLIENT_CONFIG = 'TEST_API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi.module.gen.ts new file mode 100644 index 000000000..88ba09097 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/testapi.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { MyHttpClient } from './testapi-client.service.gen'; + +import { TestApiDefaultService } from './services/testapi-default.service.gen'; + +import { TestApiSimpleService } from './services/testapi-simple.service.gen'; + +import { TestApiParametersService } from './services/testapi-parameters.service.gen'; + +import { TestApiDescriptionsService } from './services/testapi-descriptions.service.gen'; + +import { TestApiDeprecatedService } from './services/testapi-deprecated.service.gen'; + +import { TestApiRequestBodyService } from './services/testapi-requestbody.service.gen'; + +import { TestApiFormDataService } from './services/testapi-formdata.service.gen'; + +import { TestApiDefaultsService } from './services/testapi-defaults.service.gen'; + +import { TestApiDuplicateService } from './services/testapi-duplicate.service.gen'; + +import { TestApiNoContentService } from './services/testapi-nocontent.service.gen'; + +import { TestApiResponseService } from './services/testapi-response.service.gen'; + +import { TestApiNoContentService } from './services/testapi-nocontent.service.gen'; + +import { TestApiMultipleTags1Service } from './services/testapi-multipletags1.service.gen'; + +import { TestApiMultipleTags2Service } from './services/testapi-multipletags2.service.gen'; + +import { TestApiMultipleTags3Service } from './services/testapi-multipletags3.service.gen'; + +import { TestApiCollectionFormatService } from './services/testapi-collectionformat.service.gen'; + +import { TestApiTypesService } from './services/testapi-types.service.gen'; + +import { TestApiUploadService } from './services/testapi-upload.service.gen'; + +import { TestApiFileResponseService } from './services/testapi-fileresponse.service.gen'; + +import { TestApiComplexService } from './services/testapi-complex.service.gen'; + +import { TestApiMultipartService } from './services/testapi-multipart.service.gen'; + +import { TestApiHeaderService } from './services/testapi-header.service.gen'; + +import { TestApiErrorService } from './services/testapi-error.service.gen'; + +import { TestApiNonAsciiÆøåÆøÅöôêÊService } from './services/testapi-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class TestApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: TestApiModule, + providers: [ + { + provide: 'TEST_API_CLIENT_CONFIG', + useValue: config + }, + MyHttpClient, + TestApiDefaultService, + TestApiSimpleService, + TestApiParametersService, + TestApiDescriptionsService, + TestApiDeprecatedService, + TestApiRequestBodyService, + TestApiFormDataService, + TestApiDefaultsService, + TestApiDuplicateService, + TestApiNoContentService, + TestApiResponseService, + TestApiNoContentService, + TestApiMultipleTags1Service, + TestApiMultipleTags2Service, + TestApiMultipleTags3Service, + TestApiCollectionFormatService, + TestApiTypesService, + TestApiUploadService, + TestApiFileResponseService, + TestApiComplexService, + TestApiMultipartService, + TestApiHeaderService, + TestApiErrorService, + TestApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + MyHttpClient, + TestApiDefaultService, + TestApiSimpleService, + TestApiParametersService, + TestApiDescriptionsService, + TestApiDeprecatedService, + TestApiRequestBodyService, + TestApiFormDataService, + TestApiDefaultsService, + TestApiDuplicateService, + TestApiNoContentService, + TestApiResponseService, + TestApiNoContentService, + TestApiMultipleTags1Service, + TestApiMultipleTags2Service, + TestApiMultipleTags3Service, + TestApiCollectionFormatService, + TestApiTypesService, + TestApiUploadService, + TestApiFileResponseService, + TestApiComplexService, + TestApiMultipartService, + TestApiHeaderService, + TestApiErrorService, + TestApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: TestApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'TEST_API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + MyHttpClient, + TestApiDefaultService, + TestApiSimpleService, + TestApiParametersService, + TestApiDescriptionsService, + TestApiDeprecatedService, + TestApiRequestBodyService, + TestApiFormDataService, + TestApiDefaultsService, + TestApiDuplicateService, + TestApiNoContentService, + TestApiResponseService, + TestApiNoContentService, + TestApiMultipleTags1Service, + TestApiMultipleTags2Service, + TestApiMultipleTags3Service, + TestApiCollectionFormatService, + TestApiTypesService, + TestApiUploadService, + TestApiFileResponseService, + TestApiComplexService, + TestApiMultipartService, + TestApiHeaderService, + TestApiErrorService, + TestApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + MyHttpClient, + TestApiDefaultService, + TestApiSimpleService, + TestApiParametersService, + TestApiDescriptionsService, + TestApiDeprecatedService, + TestApiRequestBodyService, + TestApiFormDataService, + TestApiDefaultsService, + TestApiDuplicateService, + TestApiNoContentService, + TestApiResponseService, + TestApiNoContentService, + TestApiMultipleTags1Service, + TestApiMultipleTags2Service, + TestApiMultipleTags3Service, + TestApiCollectionFormatService, + TestApiTypesService, + TestApiUploadService, + TestApiFileResponseService, + TestApiComplexService, + TestApiMultipartService, + TestApiHeaderService, + TestApiErrorService, + TestApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/sdk.gen.ts new file mode 100644 index 000000000..e79f50b13 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-class-name/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi-client.service.gen.ts new file mode 100644 index 000000000..875fbdd56 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class MyApiClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('MY_API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const MY_API_CLIENT_CONFIG = 'MY_API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi.module.gen.ts new file mode 100644 index 000000000..0563bde45 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/myapi.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { MyApiClient } from './myapi-client.service.gen'; + +import { MyApiDefaultService } from './services/myapi-default.service.gen'; + +import { MyApiSimpleService } from './services/myapi-simple.service.gen'; + +import { MyApiParametersService } from './services/myapi-parameters.service.gen'; + +import { MyApiDescriptionsService } from './services/myapi-descriptions.service.gen'; + +import { MyApiDeprecatedService } from './services/myapi-deprecated.service.gen'; + +import { MyApiRequestBodyService } from './services/myapi-requestbody.service.gen'; + +import { MyApiFormDataService } from './services/myapi-formdata.service.gen'; + +import { MyApiDefaultsService } from './services/myapi-defaults.service.gen'; + +import { MyApiDuplicateService } from './services/myapi-duplicate.service.gen'; + +import { MyApiNoContentService } from './services/myapi-nocontent.service.gen'; + +import { MyApiResponseService } from './services/myapi-response.service.gen'; + +import { MyApiNoContentService } from './services/myapi-nocontent.service.gen'; + +import { MyApiMultipleTags1Service } from './services/myapi-multipletags1.service.gen'; + +import { MyApiMultipleTags2Service } from './services/myapi-multipletags2.service.gen'; + +import { MyApiMultipleTags3Service } from './services/myapi-multipletags3.service.gen'; + +import { MyApiCollectionFormatService } from './services/myapi-collectionformat.service.gen'; + +import { MyApiTypesService } from './services/myapi-types.service.gen'; + +import { MyApiUploadService } from './services/myapi-upload.service.gen'; + +import { MyApiFileResponseService } from './services/myapi-fileresponse.service.gen'; + +import { MyApiComplexService } from './services/myapi-complex.service.gen'; + +import { MyApiMultipartService } from './services/myapi-multipart.service.gen'; + +import { MyApiHeaderService } from './services/myapi-header.service.gen'; + +import { MyApiErrorService } from './services/myapi-error.service.gen'; + +import { MyApiNonAsciiÆøåÆøÅöôêÊService } from './services/myapi-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class MyApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: MyApiModule, + providers: [ + { + provide: 'MY_API_CLIENT_CONFIG', + useValue: config + }, + MyApiClient, + MyApiDefaultService, + MyApiSimpleService, + MyApiParametersService, + MyApiDescriptionsService, + MyApiDeprecatedService, + MyApiRequestBodyService, + MyApiFormDataService, + MyApiDefaultsService, + MyApiDuplicateService, + MyApiNoContentService, + MyApiResponseService, + MyApiNoContentService, + MyApiMultipleTags1Service, + MyApiMultipleTags2Service, + MyApiMultipleTags3Service, + MyApiCollectionFormatService, + MyApiTypesService, + MyApiUploadService, + MyApiFileResponseService, + MyApiComplexService, + MyApiMultipartService, + MyApiHeaderService, + MyApiErrorService, + MyApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + MyApiClient, + MyApiDefaultService, + MyApiSimpleService, + MyApiParametersService, + MyApiDescriptionsService, + MyApiDeprecatedService, + MyApiRequestBodyService, + MyApiFormDataService, + MyApiDefaultsService, + MyApiDuplicateService, + MyApiNoContentService, + MyApiResponseService, + MyApiNoContentService, + MyApiMultipleTags1Service, + MyApiMultipleTags2Service, + MyApiMultipleTags3Service, + MyApiCollectionFormatService, + MyApiTypesService, + MyApiUploadService, + MyApiFileResponseService, + MyApiComplexService, + MyApiMultipartService, + MyApiHeaderService, + MyApiErrorService, + MyApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: MyApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'MY_API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + MyApiClient, + MyApiDefaultService, + MyApiSimpleService, + MyApiParametersService, + MyApiDescriptionsService, + MyApiDeprecatedService, + MyApiRequestBodyService, + MyApiFormDataService, + MyApiDefaultsService, + MyApiDuplicateService, + MyApiNoContentService, + MyApiResponseService, + MyApiNoContentService, + MyApiMultipleTags1Service, + MyApiMultipleTags2Service, + MyApiMultipleTags3Service, + MyApiCollectionFormatService, + MyApiTypesService, + MyApiUploadService, + MyApiFileResponseService, + MyApiComplexService, + MyApiMultipartService, + MyApiHeaderService, + MyApiErrorService, + MyApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + MyApiClient, + MyApiDefaultService, + MyApiSimpleService, + MyApiParametersService, + MyApiDescriptionsService, + MyApiDeprecatedService, + MyApiRequestBodyService, + MyApiFormDataService, + MyApiDefaultsService, + MyApiDuplicateService, + MyApiNoContentService, + MyApiResponseService, + MyApiNoContentService, + MyApiMultipleTags1Service, + MyApiMultipleTags2Service, + MyApiMultipleTags3Service, + MyApiCollectionFormatService, + MyApiTypesService, + MyApiUploadService, + MyApiFileResponseService, + MyApiComplexService, + MyApiMultipartService, + MyApiHeaderService, + MyApiErrorService, + MyApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-collectionformat.service.gen.ts new file mode 100644 index 000000000..6190f6daf --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class MyApiCollectionFormatService { + constructor(private readonly client: MyApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-complex.service.gen.ts new file mode 100644 index 000000000..80c6e7044 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class MyApiComplexService { + constructor(private readonly client: MyApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-default.service.gen.ts new file mode 100644 index 000000000..f03d0cf6d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class MyApiDefaultService { + constructor(private readonly client: MyApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-defaults.service.gen.ts new file mode 100644 index 000000000..5112b3dd4 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class MyApiDefaultsService { + constructor(private readonly client: MyApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-deprecated.service.gen.ts new file mode 100644 index 000000000..2998baf4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class MyApiDeprecatedService { + constructor(private readonly client: MyApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-descriptions.service.gen.ts new file mode 100644 index 000000000..7143e374b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class MyApiDescriptionsService { + constructor(private readonly client: MyApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-duplicate.service.gen.ts new file mode 100644 index 000000000..64f9fcbc0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class MyApiDuplicateService { + constructor(private readonly client: MyApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-error.service.gen.ts new file mode 100644 index 000000000..0b92e68f7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class MyApiErrorService { + constructor(private readonly client: MyApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-fileresponse.service.gen.ts new file mode 100644 index 000000000..a7416a6eb --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class MyApiFileResponseService { + constructor(private readonly client: MyApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-formdata.service.gen.ts new file mode 100644 index 000000000..a2f86b5e9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class MyApiFormDataService { + constructor(private readonly client: MyApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-header.service.gen.ts new file mode 100644 index 000000000..57e1826c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class MyApiHeaderService { + constructor(private readonly client: MyApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipart.service.gen.ts new file mode 100644 index 000000000..947466984 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class MyApiMultipartService { + constructor(private readonly client: MyApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags1.service.gen.ts new file mode 100644 index 000000000..048cdde5b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class MyApiMultipleTags1Service { + constructor(private readonly client: MyApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags2.service.gen.ts new file mode 100644 index 000000000..87cb48fce --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class MyApiMultipleTags2Service { + constructor(private readonly client: MyApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags3.service.gen.ts new file mode 100644 index 000000000..4ee02ad17 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class MyApiMultipleTags3Service { + constructor(private readonly client: MyApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-nocontent.service.gen.ts new file mode 100644 index 000000000..841683305 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class MyApiNoContentService { + constructor(private readonly client: MyApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..217e58c30 --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class MyApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: MyApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-parameters.service.gen.ts new file mode 100644 index 000000000..b79b81318 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class MyApiParametersService { + constructor(private readonly client: MyApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-requestbody.service.gen.ts new file mode 100644 index 000000000..db5e35f00 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class MyApiRequestBodyService { + constructor(private readonly client: MyApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-response.service.gen.ts new file mode 100644 index 000000000..e99a514ff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class MyApiResponseService { + constructor(private readonly client: MyApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-simple.service.gen.ts new file mode 100644 index 000000000..78c1aa36f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class MyApiSimpleService { + constructor(private readonly client: MyApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-types.service.gen.ts new file mode 100644 index 000000000..686a3293f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class MyApiTypesService { + constructor(private readonly client: MyApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-upload.service.gen.ts new file mode 100644 index 000000000..be2f98397 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/services/myapi-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { MyApiClient } from '../myapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class MyApiUploadService { + constructor(private readonly client: MyApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/sdk.gen.ts new file mode 100644 index 000000000..e79f50b13 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-client-name/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi-client.service.gen.ts new file mode 100644 index 000000000..16a79f839 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class SuperClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('ADVANCED_API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const ADVANCED_API_CLIENT_CONFIG = 'ADVANCED_API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi.module.gen.ts new file mode 100644 index 000000000..ca6260eba --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/advancedapi.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { SuperClient } from './advancedapi-client.service.gen'; + +import { AdvancedApiDefaultService } from './services/advancedapi-default.service.gen'; + +import { AdvancedApiSimpleService } from './services/advancedapi-simple.service.gen'; + +import { AdvancedApiParametersService } from './services/advancedapi-parameters.service.gen'; + +import { AdvancedApiDescriptionsService } from './services/advancedapi-descriptions.service.gen'; + +import { AdvancedApiDeprecatedService } from './services/advancedapi-deprecated.service.gen'; + +import { AdvancedApiRequestBodyService } from './services/advancedapi-requestbody.service.gen'; + +import { AdvancedApiFormDataService } from './services/advancedapi-formdata.service.gen'; + +import { AdvancedApiDefaultsService } from './services/advancedapi-defaults.service.gen'; + +import { AdvancedApiDuplicateService } from './services/advancedapi-duplicate.service.gen'; + +import { AdvancedApiNoContentService } from './services/advancedapi-nocontent.service.gen'; + +import { AdvancedApiResponseService } from './services/advancedapi-response.service.gen'; + +import { AdvancedApiNoContentService } from './services/advancedapi-nocontent.service.gen'; + +import { AdvancedApiMultipleTags1Service } from './services/advancedapi-multipletags1.service.gen'; + +import { AdvancedApiMultipleTags2Service } from './services/advancedapi-multipletags2.service.gen'; + +import { AdvancedApiMultipleTags3Service } from './services/advancedapi-multipletags3.service.gen'; + +import { AdvancedApiCollectionFormatService } from './services/advancedapi-collectionformat.service.gen'; + +import { AdvancedApiTypesService } from './services/advancedapi-types.service.gen'; + +import { AdvancedApiUploadService } from './services/advancedapi-upload.service.gen'; + +import { AdvancedApiFileResponseService } from './services/advancedapi-fileresponse.service.gen'; + +import { AdvancedApiComplexService } from './services/advancedapi-complex.service.gen'; + +import { AdvancedApiMultipartService } from './services/advancedapi-multipart.service.gen'; + +import { AdvancedApiHeaderService } from './services/advancedapi-header.service.gen'; + +import { AdvancedApiErrorService } from './services/advancedapi-error.service.gen'; + +import { AdvancedApiNonAsciiÆøåÆøÅöôêÊService } from './services/advancedapi-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class AdvancedApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: AdvancedApiModule, + providers: [ + { + provide: 'ADVANCED_API_CLIENT_CONFIG', + useValue: config + }, + SuperClient, + AdvancedApiDefaultService, + AdvancedApiSimpleService, + AdvancedApiParametersService, + AdvancedApiDescriptionsService, + AdvancedApiDeprecatedService, + AdvancedApiRequestBodyService, + AdvancedApiFormDataService, + AdvancedApiDefaultsService, + AdvancedApiDuplicateService, + AdvancedApiNoContentService, + AdvancedApiResponseService, + AdvancedApiNoContentService, + AdvancedApiMultipleTags1Service, + AdvancedApiMultipleTags2Service, + AdvancedApiMultipleTags3Service, + AdvancedApiCollectionFormatService, + AdvancedApiTypesService, + AdvancedApiUploadService, + AdvancedApiFileResponseService, + AdvancedApiComplexService, + AdvancedApiMultipartService, + AdvancedApiHeaderService, + AdvancedApiErrorService, + AdvancedApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + SuperClient, + AdvancedApiDefaultService, + AdvancedApiSimpleService, + AdvancedApiParametersService, + AdvancedApiDescriptionsService, + AdvancedApiDeprecatedService, + AdvancedApiRequestBodyService, + AdvancedApiFormDataService, + AdvancedApiDefaultsService, + AdvancedApiDuplicateService, + AdvancedApiNoContentService, + AdvancedApiResponseService, + AdvancedApiNoContentService, + AdvancedApiMultipleTags1Service, + AdvancedApiMultipleTags2Service, + AdvancedApiMultipleTags3Service, + AdvancedApiCollectionFormatService, + AdvancedApiTypesService, + AdvancedApiUploadService, + AdvancedApiFileResponseService, + AdvancedApiComplexService, + AdvancedApiMultipartService, + AdvancedApiHeaderService, + AdvancedApiErrorService, + AdvancedApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: AdvancedApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'ADVANCED_API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + SuperClient, + AdvancedApiDefaultService, + AdvancedApiSimpleService, + AdvancedApiParametersService, + AdvancedApiDescriptionsService, + AdvancedApiDeprecatedService, + AdvancedApiRequestBodyService, + AdvancedApiFormDataService, + AdvancedApiDefaultsService, + AdvancedApiDuplicateService, + AdvancedApiNoContentService, + AdvancedApiResponseService, + AdvancedApiNoContentService, + AdvancedApiMultipleTags1Service, + AdvancedApiMultipleTags2Service, + AdvancedApiMultipleTags3Service, + AdvancedApiCollectionFormatService, + AdvancedApiTypesService, + AdvancedApiUploadService, + AdvancedApiFileResponseService, + AdvancedApiComplexService, + AdvancedApiMultipartService, + AdvancedApiHeaderService, + AdvancedApiErrorService, + AdvancedApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + SuperClient, + AdvancedApiDefaultService, + AdvancedApiSimpleService, + AdvancedApiParametersService, + AdvancedApiDescriptionsService, + AdvancedApiDeprecatedService, + AdvancedApiRequestBodyService, + AdvancedApiFormDataService, + AdvancedApiDefaultsService, + AdvancedApiDuplicateService, + AdvancedApiNoContentService, + AdvancedApiResponseService, + AdvancedApiNoContentService, + AdvancedApiMultipleTags1Service, + AdvancedApiMultipleTags2Service, + AdvancedApiMultipleTags3Service, + AdvancedApiCollectionFormatService, + AdvancedApiTypesService, + AdvancedApiUploadService, + AdvancedApiFileResponseService, + AdvancedApiComplexService, + AdvancedApiMultipartService, + AdvancedApiHeaderService, + AdvancedApiErrorService, + AdvancedApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-collectionformat.service.gen.ts new file mode 100644 index 000000000..2b6044023 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiCollectionFormatService { + constructor(private readonly client: AdvancedApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-complex.service.gen.ts new file mode 100644 index 000000000..490e13dc3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiComplexService { + constructor(private readonly client: AdvancedApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-default.service.gen.ts new file mode 100644 index 000000000..2b87722e1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiDefaultService { + constructor(private readonly client: AdvancedApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-defaults.service.gen.ts new file mode 100644 index 000000000..33bbb3c47 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiDefaultsService { + constructor(private readonly client: AdvancedApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-deprecated.service.gen.ts new file mode 100644 index 000000000..d9d08f937 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiDeprecatedService { + constructor(private readonly client: AdvancedApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-descriptions.service.gen.ts new file mode 100644 index 000000000..9933d0b77 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiDescriptionsService { + constructor(private readonly client: AdvancedApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-duplicate.service.gen.ts new file mode 100644 index 000000000..6318632de --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class AdvancedApiDuplicateService { + constructor(private readonly client: AdvancedApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-error.service.gen.ts new file mode 100644 index 000000000..d82e1ee03 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiErrorService { + constructor(private readonly client: AdvancedApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-fileresponse.service.gen.ts new file mode 100644 index 000000000..aae70e3c7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiFileResponseService { + constructor(private readonly client: AdvancedApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-formdata.service.gen.ts new file mode 100644 index 000000000..dbb37c70f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiFormDataService { + constructor(private readonly client: AdvancedApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-header.service.gen.ts new file mode 100644 index 000000000..f541abb1a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiHeaderService { + constructor(private readonly client: AdvancedApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipart.service.gen.ts new file mode 100644 index 000000000..ab945bcdc --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiMultipartService { + constructor(private readonly client: AdvancedApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags1.service.gen.ts new file mode 100644 index 000000000..dc379c105 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiMultipleTags1Service { + constructor(private readonly client: AdvancedApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags2.service.gen.ts new file mode 100644 index 000000000..4ca0d299c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiMultipleTags2Service { + constructor(private readonly client: AdvancedApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags3.service.gen.ts new file mode 100644 index 000000000..bbe1749e0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiMultipleTags3Service { + constructor(private readonly client: AdvancedApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-nocontent.service.gen.ts new file mode 100644 index 000000000..ed4a57411 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiNoContentService { + constructor(private readonly client: AdvancedApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..e5758f4f9 --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: AdvancedApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-parameters.service.gen.ts new file mode 100644 index 000000000..c74005859 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiParametersService { + constructor(private readonly client: AdvancedApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-requestbody.service.gen.ts new file mode 100644 index 000000000..956f17a4c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiRequestBodyService { + constructor(private readonly client: AdvancedApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-response.service.gen.ts new file mode 100644 index 000000000..e358eb683 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiResponseService { + constructor(private readonly client: AdvancedApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-simple.service.gen.ts new file mode 100644 index 000000000..f8c8575c5 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class AdvancedApiSimpleService { + constructor(private readonly client: AdvancedApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-types.service.gen.ts new file mode 100644 index 000000000..bbb094db7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiTypesService { + constructor(private readonly client: AdvancedApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-upload.service.gen.ts new file mode 100644 index 000000000..ecbb06e79 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/services/advancedapi-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { AdvancedApiClient } from '../advancedapi-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class AdvancedApiUploadService { + constructor(private readonly client: AdvancedApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/sdk.gen.ts new file mode 100644 index 000000000..e54e0318f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-config-combined/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient-client.service.gen.ts new file mode 100644 index 000000000..e93af1fdb --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class CustomClientClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('CUSTOM_CLIENT_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const CUSTOM_CLIENT_CLIENT_CONFIG = 'CUSTOM_CLIENT_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient.module.gen.ts new file mode 100644 index 000000000..ca39f33e9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/customclient.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { CustomClientClient } from './customclient-client.service.gen'; + +import { CustomClientDefaultService } from './services/customclient-default.service.gen'; + +import { CustomClientSimpleService } from './services/customclient-simple.service.gen'; + +import { CustomClientParametersService } from './services/customclient-parameters.service.gen'; + +import { CustomClientDescriptionsService } from './services/customclient-descriptions.service.gen'; + +import { CustomClientDeprecatedService } from './services/customclient-deprecated.service.gen'; + +import { CustomClientRequestBodyService } from './services/customclient-requestbody.service.gen'; + +import { CustomClientFormDataService } from './services/customclient-formdata.service.gen'; + +import { CustomClientDefaultsService } from './services/customclient-defaults.service.gen'; + +import { CustomClientDuplicateService } from './services/customclient-duplicate.service.gen'; + +import { CustomClientNoContentService } from './services/customclient-nocontent.service.gen'; + +import { CustomClientResponseService } from './services/customclient-response.service.gen'; + +import { CustomClientNoContentService } from './services/customclient-nocontent.service.gen'; + +import { CustomClientMultipleTags1Service } from './services/customclient-multipletags1.service.gen'; + +import { CustomClientMultipleTags2Service } from './services/customclient-multipletags2.service.gen'; + +import { CustomClientMultipleTags3Service } from './services/customclient-multipletags3.service.gen'; + +import { CustomClientCollectionFormatService } from './services/customclient-collectionformat.service.gen'; + +import { CustomClientTypesService } from './services/customclient-types.service.gen'; + +import { CustomClientUploadService } from './services/customclient-upload.service.gen'; + +import { CustomClientFileResponseService } from './services/customclient-fileresponse.service.gen'; + +import { CustomClientComplexService } from './services/customclient-complex.service.gen'; + +import { CustomClientMultipartService } from './services/customclient-multipart.service.gen'; + +import { CustomClientHeaderService } from './services/customclient-header.service.gen'; + +import { CustomClientErrorService } from './services/customclient-error.service.gen'; + +import { CustomClientNonAsciiÆøåÆøÅöôêÊService } from './services/customclient-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class MyCustomModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: MyCustomModule, + providers: [ + { + provide: 'CUSTOM_CLIENT_CLIENT_CONFIG', + useValue: config + }, + CustomClientClient, + CustomClientDefaultService, + CustomClientSimpleService, + CustomClientParametersService, + CustomClientDescriptionsService, + CustomClientDeprecatedService, + CustomClientRequestBodyService, + CustomClientFormDataService, + CustomClientDefaultsService, + CustomClientDuplicateService, + CustomClientNoContentService, + CustomClientResponseService, + CustomClientNoContentService, + CustomClientMultipleTags1Service, + CustomClientMultipleTags2Service, + CustomClientMultipleTags3Service, + CustomClientCollectionFormatService, + CustomClientTypesService, + CustomClientUploadService, + CustomClientFileResponseService, + CustomClientComplexService, + CustomClientMultipartService, + CustomClientHeaderService, + CustomClientErrorService, + CustomClientNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + CustomClientClient, + CustomClientDefaultService, + CustomClientSimpleService, + CustomClientParametersService, + CustomClientDescriptionsService, + CustomClientDeprecatedService, + CustomClientRequestBodyService, + CustomClientFormDataService, + CustomClientDefaultsService, + CustomClientDuplicateService, + CustomClientNoContentService, + CustomClientResponseService, + CustomClientNoContentService, + CustomClientMultipleTags1Service, + CustomClientMultipleTags2Service, + CustomClientMultipleTags3Service, + CustomClientCollectionFormatService, + CustomClientTypesService, + CustomClientUploadService, + CustomClientFileResponseService, + CustomClientComplexService, + CustomClientMultipartService, + CustomClientHeaderService, + CustomClientErrorService, + CustomClientNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: MyCustomModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'CUSTOM_CLIENT_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + CustomClientClient, + CustomClientDefaultService, + CustomClientSimpleService, + CustomClientParametersService, + CustomClientDescriptionsService, + CustomClientDeprecatedService, + CustomClientRequestBodyService, + CustomClientFormDataService, + CustomClientDefaultsService, + CustomClientDuplicateService, + CustomClientNoContentService, + CustomClientResponseService, + CustomClientNoContentService, + CustomClientMultipleTags1Service, + CustomClientMultipleTags2Service, + CustomClientMultipleTags3Service, + CustomClientCollectionFormatService, + CustomClientTypesService, + CustomClientUploadService, + CustomClientFileResponseService, + CustomClientComplexService, + CustomClientMultipartService, + CustomClientHeaderService, + CustomClientErrorService, + CustomClientNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + CustomClientClient, + CustomClientDefaultService, + CustomClientSimpleService, + CustomClientParametersService, + CustomClientDescriptionsService, + CustomClientDeprecatedService, + CustomClientRequestBodyService, + CustomClientFormDataService, + CustomClientDefaultsService, + CustomClientDuplicateService, + CustomClientNoContentService, + CustomClientResponseService, + CustomClientNoContentService, + CustomClientMultipleTags1Service, + CustomClientMultipleTags2Service, + CustomClientMultipleTags3Service, + CustomClientCollectionFormatService, + CustomClientTypesService, + CustomClientUploadService, + CustomClientFileResponseService, + CustomClientComplexService, + CustomClientMultipartService, + CustomClientHeaderService, + CustomClientErrorService, + CustomClientNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-collectionformat.service.gen.ts new file mode 100644 index 000000000..652d8c3f4 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class CustomClientCollectionFormatService { + constructor(private readonly client: CustomClientClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-complex.service.gen.ts new file mode 100644 index 000000000..5f582f8c6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientComplexService { + constructor(private readonly client: CustomClientClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-default.service.gen.ts new file mode 100644 index 000000000..377d0aa78 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientDefaultService { + constructor(private readonly client: CustomClientClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-defaults.service.gen.ts new file mode 100644 index 000000000..c84361621 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class CustomClientDefaultsService { + constructor(private readonly client: CustomClientClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-deprecated.service.gen.ts new file mode 100644 index 000000000..1e47296a6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class CustomClientDeprecatedService { + constructor(private readonly client: CustomClientClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-descriptions.service.gen.ts new file mode 100644 index 000000000..0926d177f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class CustomClientDescriptionsService { + constructor(private readonly client: CustomClientClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-duplicate.service.gen.ts new file mode 100644 index 000000000..e65567e93 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class CustomClientDuplicateService { + constructor(private readonly client: CustomClientClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-error.service.gen.ts new file mode 100644 index 000000000..85585f1c2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientErrorService { + constructor(private readonly client: CustomClientClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-fileresponse.service.gen.ts new file mode 100644 index 000000000..172b0ca6f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientFileResponseService { + constructor(private readonly client: CustomClientClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-formdata.service.gen.ts new file mode 100644 index 000000000..1f1ddbe68 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class CustomClientFormDataService { + constructor(private readonly client: CustomClientClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-header.service.gen.ts new file mode 100644 index 000000000..9448fca52 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientHeaderService { + constructor(private readonly client: CustomClientClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipart.service.gen.ts new file mode 100644 index 000000000..b6d747dd5 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class CustomClientMultipartService { + constructor(private readonly client: CustomClientClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags1.service.gen.ts new file mode 100644 index 000000000..4d9fb0cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientMultipleTags1Service { + constructor(private readonly client: CustomClientClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags2.service.gen.ts new file mode 100644 index 000000000..6a17bf69e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientMultipleTags2Service { + constructor(private readonly client: CustomClientClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags3.service.gen.ts new file mode 100644 index 000000000..cb1ff0f92 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientMultipleTags3Service { + constructor(private readonly client: CustomClientClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-nocontent.service.gen.ts new file mode 100644 index 000000000..7cf7eef21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientNoContentService { + constructor(private readonly client: CustomClientClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..62e46666d --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class CustomClientNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: CustomClientClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-parameters.service.gen.ts new file mode 100644 index 000000000..ed2c928c2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientParametersService { + constructor(private readonly client: CustomClientClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-requestbody.service.gen.ts new file mode 100644 index 000000000..e416a6075 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class CustomClientRequestBodyService { + constructor(private readonly client: CustomClientClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-response.service.gen.ts new file mode 100644 index 000000000..c3cce1d60 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientResponseService { + constructor(private readonly client: CustomClientClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-simple.service.gen.ts new file mode 100644 index 000000000..128c01ca5 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class CustomClientSimpleService { + constructor(private readonly client: CustomClientClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-types.service.gen.ts new file mode 100644 index 000000000..36b24f108 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientTypesService { + constructor(private readonly client: CustomClientClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-upload.service.gen.ts new file mode 100644 index 000000000..30fddb680 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/services/customclient-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { CustomClientClient } from '../customclient-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class CustomClientUploadService { + constructor(private readonly client: CustomClientClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/sdk.gen.ts new file mode 100644 index 000000000..e79f50b13 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/custom-module-name/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client.gen.ts new file mode 100644 index 000000000..c8e1b2349 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from '@hey-api/client-nestjs'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api-client.service.gen.ts new file mode 100644 index 000000000..ddc0e43a0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class ApiClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const API_CLIENT_CONFIG = 'API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api.module.gen.ts new file mode 100644 index 000000000..ddd6e339c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/api.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { ApiClient } from './api-client.service.gen'; + +import { ApiDefaultService } from './services/api-default.service.gen'; + +import { ApiSimpleService } from './services/api-simple.service.gen'; + +import { ApiParametersService } from './services/api-parameters.service.gen'; + +import { ApiDescriptionsService } from './services/api-descriptions.service.gen'; + +import { ApiDeprecatedService } from './services/api-deprecated.service.gen'; + +import { ApiRequestBodyService } from './services/api-requestbody.service.gen'; + +import { ApiFormDataService } from './services/api-formdata.service.gen'; + +import { ApiDefaultsService } from './services/api-defaults.service.gen'; + +import { ApiDuplicateService } from './services/api-duplicate.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiResponseService } from './services/api-response.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiMultipleTags1Service } from './services/api-multipletags1.service.gen'; + +import { ApiMultipleTags2Service } from './services/api-multipletags2.service.gen'; + +import { ApiMultipleTags3Service } from './services/api-multipletags3.service.gen'; + +import { ApiCollectionFormatService } from './services/api-collectionformat.service.gen'; + +import { ApiTypesService } from './services/api-types.service.gen'; + +import { ApiUploadService } from './services/api-upload.service.gen'; + +import { ApiFileResponseService } from './services/api-fileresponse.service.gen'; + +import { ApiComplexService } from './services/api-complex.service.gen'; + +import { ApiMultipartService } from './services/api-multipart.service.gen'; + +import { ApiHeaderService } from './services/api-header.service.gen'; + +import { ApiErrorService } from './services/api-error.service.gen'; + +import { ApiNonAsciiÆøåÆøÅöôêÊService } from './services/api-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class ApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: ApiModule, + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useValue: config + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: ApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-collectionformat.service.gen.ts new file mode 100644 index 000000000..5546e7e60 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class ApiCollectionFormatService { + constructor(private readonly client: ApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-complex.service.gen.ts new file mode 100644 index 000000000..ab9d15b3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class ApiComplexService { + constructor(private readonly client: ApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-default.service.gen.ts new file mode 100644 index 000000000..7d4e4716c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class ApiDefaultService { + constructor(private readonly client: ApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-defaults.service.gen.ts new file mode 100644 index 000000000..f0e60983c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class ApiDefaultsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-deprecated.service.gen.ts new file mode 100644 index 000000000..0c30727d8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class ApiDeprecatedService { + constructor(private readonly client: ApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-descriptions.service.gen.ts new file mode 100644 index 000000000..6a8839bf8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class ApiDescriptionsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-duplicate.service.gen.ts new file mode 100644 index 000000000..3ae1e3458 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class ApiDuplicateService { + constructor(private readonly client: ApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-error.service.gen.ts new file mode 100644 index 000000000..2435ca78c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class ApiErrorService { + constructor(private readonly client: ApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-fileresponse.service.gen.ts new file mode 100644 index 000000000..30977163e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiFileResponseService { + constructor(private readonly client: ApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-formdata.service.gen.ts new file mode 100644 index 000000000..7f0627712 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class ApiFormDataService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-header.service.gen.ts new file mode 100644 index 000000000..f3404da09 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class ApiHeaderService { + constructor(private readonly client: ApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipart.service.gen.ts new file mode 100644 index 000000000..69326948d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class ApiMultipartService { + constructor(private readonly client: ApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags1.service.gen.ts new file mode 100644 index 000000000..903a1497b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags1Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags2.service.gen.ts new file mode 100644 index 000000000..c0f73ad6c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags2Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags3.service.gen.ts new file mode 100644 index 000000000..f56684cfd --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags3Service { + constructor(private readonly client: ApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-nocontent.service.gen.ts new file mode 100644 index 000000000..9c51f8923 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiNoContentService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..4e288b7dc --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class ApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: ApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-parameters.service.gen.ts new file mode 100644 index 000000000..8bf767f3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class ApiParametersService { + constructor(private readonly client: ApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-requestbody.service.gen.ts new file mode 100644 index 000000000..7d3c1be6e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class ApiRequestBodyService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-response.service.gen.ts new file mode 100644 index 000000000..426e47705 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class ApiResponseService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-simple.service.gen.ts new file mode 100644 index 000000000..3d9ed4cc8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class ApiSimpleService { + constructor(private readonly client: ApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-types.service.gen.ts new file mode 100644 index 000000000..d993617ac --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class ApiTypesService { + constructor(private readonly client: ApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-upload.service.gen.ts new file mode 100644 index 000000000..b967a2e05 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/client/services/api-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class ApiUploadService { + constructor(private readonly client: ApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/sdk.gen.ts new file mode 100644 index 000000000..596c06fe0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/client-nestjs'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/no-bundle/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api-client.service.gen.ts new file mode 100644 index 000000000..ddc0e43a0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class ApiClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const API_CLIENT_CONFIG = 'API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api.module.gen.ts new file mode 100644 index 000000000..ddd6e339c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/api.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { ApiClient } from './api-client.service.gen'; + +import { ApiDefaultService } from './services/api-default.service.gen'; + +import { ApiSimpleService } from './services/api-simple.service.gen'; + +import { ApiParametersService } from './services/api-parameters.service.gen'; + +import { ApiDescriptionsService } from './services/api-descriptions.service.gen'; + +import { ApiDeprecatedService } from './services/api-deprecated.service.gen'; + +import { ApiRequestBodyService } from './services/api-requestbody.service.gen'; + +import { ApiFormDataService } from './services/api-formdata.service.gen'; + +import { ApiDefaultsService } from './services/api-defaults.service.gen'; + +import { ApiDuplicateService } from './services/api-duplicate.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiResponseService } from './services/api-response.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiMultipleTags1Service } from './services/api-multipletags1.service.gen'; + +import { ApiMultipleTags2Service } from './services/api-multipletags2.service.gen'; + +import { ApiMultipleTags3Service } from './services/api-multipletags3.service.gen'; + +import { ApiCollectionFormatService } from './services/api-collectionformat.service.gen'; + +import { ApiTypesService } from './services/api-types.service.gen'; + +import { ApiUploadService } from './services/api-upload.service.gen'; + +import { ApiFileResponseService } from './services/api-fileresponse.service.gen'; + +import { ApiComplexService } from './services/api-complex.service.gen'; + +import { ApiMultipartService } from './services/api-multipart.service.gen'; + +import { ApiHeaderService } from './services/api-header.service.gen'; + +import { ApiErrorService } from './services/api-error.service.gen'; + +import { ApiNonAsciiÆøåÆøÅöôêÊService } from './services/api-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class ApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: ApiModule, + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useValue: config + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: ApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-collectionformat.service.gen.ts new file mode 100644 index 000000000..5546e7e60 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class ApiCollectionFormatService { + constructor(private readonly client: ApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-complex.service.gen.ts new file mode 100644 index 000000000..ab9d15b3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class ApiComplexService { + constructor(private readonly client: ApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-default.service.gen.ts new file mode 100644 index 000000000..7d4e4716c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class ApiDefaultService { + constructor(private readonly client: ApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-defaults.service.gen.ts new file mode 100644 index 000000000..f0e60983c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class ApiDefaultsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-deprecated.service.gen.ts new file mode 100644 index 000000000..0c30727d8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class ApiDeprecatedService { + constructor(private readonly client: ApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-descriptions.service.gen.ts new file mode 100644 index 000000000..6a8839bf8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class ApiDescriptionsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-duplicate.service.gen.ts new file mode 100644 index 000000000..3ae1e3458 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class ApiDuplicateService { + constructor(private readonly client: ApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-error.service.gen.ts new file mode 100644 index 000000000..2435ca78c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class ApiErrorService { + constructor(private readonly client: ApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-fileresponse.service.gen.ts new file mode 100644 index 000000000..30977163e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiFileResponseService { + constructor(private readonly client: ApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-formdata.service.gen.ts new file mode 100644 index 000000000..7f0627712 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class ApiFormDataService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-header.service.gen.ts new file mode 100644 index 000000000..f3404da09 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class ApiHeaderService { + constructor(private readonly client: ApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipart.service.gen.ts new file mode 100644 index 000000000..69326948d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class ApiMultipartService { + constructor(private readonly client: ApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags1.service.gen.ts new file mode 100644 index 000000000..903a1497b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags1Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags2.service.gen.ts new file mode 100644 index 000000000..c0f73ad6c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags2Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags3.service.gen.ts new file mode 100644 index 000000000..f56684cfd --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags3Service { + constructor(private readonly client: ApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-nocontent.service.gen.ts new file mode 100644 index 000000000..9c51f8923 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiNoContentService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..4e288b7dc --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class ApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: ApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-parameters.service.gen.ts new file mode 100644 index 000000000..8bf767f3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class ApiParametersService { + constructor(private readonly client: ApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-requestbody.service.gen.ts new file mode 100644 index 000000000..7d3c1be6e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class ApiRequestBodyService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-response.service.gen.ts new file mode 100644 index 000000000..426e47705 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class ApiResponseService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-simple.service.gen.ts new file mode 100644 index 000000000..3d9ed4cc8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class ApiSimpleService { + constructor(private readonly client: ApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-types.service.gen.ts new file mode 100644 index 000000000..d993617ac --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class ApiTypesService { + constructor(private readonly client: ApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-upload.service.gen.ts new file mode 100644 index 000000000..b967a2e05 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/services/api-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class ApiUploadService { + constructor(private readonly client: ApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/sdk.gen.ts new file mode 100644 index 000000000..e79f50b13 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-false/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client.gen.ts new file mode 100644 index 000000000..749544cd9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client.gen.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import type { Config, ClientOptions as DefaultClientOptions } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api-client.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api-client.service.gen.ts new file mode 100644 index 000000000..ddc0e43a0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api-client.service.gen.ts @@ -0,0 +1,90 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable, Inject } from '@nestjs/common'; + +import axios from 'axios'; + +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios'; + +import type { ClientModuleConfig, RequestOptions } from './types.gen'; + +@Injectable() +export class ApiClient { + private axiosInstance: AxiosInstance; + constructor( + @Inject('API_CLIENT_CONFIG') + private readonly config: ClientModuleConfig) { + const axiosConfig = { + baseURL: config.baseUrl, + headers: config.headers, + timeout: 5000, + ...config.axiosConfig + }; + this.axiosInstance = axios.create(axiosConfig); + } + public request(options: RequestOptions): Promise> { + const config: AxiosRequestConfig = { + method: options.method, + url: options.url, + headers: options.headers as RawAxiosRequestHeaders, + params: options.query, + data: options.body, + timeout: options.timeout + }; + return this.axiosInstance(config); + } + public get(url: string, options: Omit): Promise> { + return this.request({ + method: 'GET', + url: url, + ...options + }); + } + public post(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'POST', + url: url, + body: data, + ...options + }); + } + public put(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PUT', + url: url, + body: data, + ...options + }); + } + public patch(url: string, data: any, options: Omit): Promise> { + return this.request({ + method: 'PATCH', + url: url, + body: data, + ...options + }); + } + public delete(url: string, options: Omit): Promise> { + return this.request({ + method: 'DELETE', + url: url, + ...options + }); + } + public head(url: string, options: Omit): Promise> { + return this.request({ + method: 'HEAD', + url: url, + ...options + }); + } + public options(url: string, options: Omit): Promise> { + return this.request({ + method: 'OPTIONS', + url: url, + ...options + }); + } +} + +export const API_CLIENT_CONFIG = 'API_CLIENT_CONFIG'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api.module.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api.module.gen.ts new file mode 100644 index 000000000..ddd6e339c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/api.module.gen.ts @@ -0,0 +1,189 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Module, DynamicModule } from '@nestjs/common'; + +import type { ClientModuleConfig, ClientModuleAsyncConfig } from './types.gen'; + +import { ApiClient } from './api-client.service.gen'; + +import { ApiDefaultService } from './services/api-default.service.gen'; + +import { ApiSimpleService } from './services/api-simple.service.gen'; + +import { ApiParametersService } from './services/api-parameters.service.gen'; + +import { ApiDescriptionsService } from './services/api-descriptions.service.gen'; + +import { ApiDeprecatedService } from './services/api-deprecated.service.gen'; + +import { ApiRequestBodyService } from './services/api-requestbody.service.gen'; + +import { ApiFormDataService } from './services/api-formdata.service.gen'; + +import { ApiDefaultsService } from './services/api-defaults.service.gen'; + +import { ApiDuplicateService } from './services/api-duplicate.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiResponseService } from './services/api-response.service.gen'; + +import { ApiNoContentService } from './services/api-nocontent.service.gen'; + +import { ApiMultipleTags1Service } from './services/api-multipletags1.service.gen'; + +import { ApiMultipleTags2Service } from './services/api-multipletags2.service.gen'; + +import { ApiMultipleTags3Service } from './services/api-multipletags3.service.gen'; + +import { ApiCollectionFormatService } from './services/api-collectionformat.service.gen'; + +import { ApiTypesService } from './services/api-types.service.gen'; + +import { ApiUploadService } from './services/api-upload.service.gen'; + +import { ApiFileResponseService } from './services/api-fileresponse.service.gen'; + +import { ApiComplexService } from './services/api-complex.service.gen'; + +import { ApiMultipartService } from './services/api-multipart.service.gen'; + +import { ApiHeaderService } from './services/api-header.service.gen'; + +import { ApiErrorService } from './services/api-error.service.gen'; + +import { ApiNonAsciiÆøåÆøÅöôêÊService } from './services/api-non-ascii-æøåæøåöôêê.service.gen'; + +@Module({}) +export class ApiModule { + public static forRoot(config: ClientModuleConfig): DynamicModule { + return { + module: ApiModule, + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useValue: config + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } + public static forRootAsync(options: ClientModuleAsyncConfig): DynamicModule { + return { + module: ApiModule, + imports: options.imports ? options.imports : [], + providers: [ + { + provide: 'API_CLIENT_CONFIG', + useFactory: options.useFactory ? options.useFactory : (): ClientModuleConfig => { + return {}; + }, + inject: options.inject ? options.inject : [] + }, + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ], + exports: [ + ApiClient, + ApiDefaultService, + ApiSimpleService, + ApiParametersService, + ApiDescriptionsService, + ApiDeprecatedService, + ApiRequestBodyService, + ApiFormDataService, + ApiDefaultsService, + ApiDuplicateService, + ApiNoContentService, + ApiResponseService, + ApiNoContentService, + ApiMultipleTags1Service, + ApiMultipleTags2Service, + ApiMultipleTags3Service, + ApiCollectionFormatService, + ApiTypesService, + ApiUploadService, + ApiFileResponseService, + ApiComplexService, + ApiMultipartService, + ApiHeaderService, + ApiErrorService, + ApiNonAsciiÆøåÆøÅöôêÊService + ] + }; + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-collectionformat.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-collectionformat.service.gen.ts new file mode 100644 index 000000000..5546e7e60 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-collectionformat.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CollectionFormatData } from '../../types.gen'; + +@Injectable() +export class ApiCollectionFormatService { + constructor(private readonly client: ApiClient) { + } + public async collectionFormat(options: CollectionFormatData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-complex.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-complex.service.gen.ts new file mode 100644 index 000000000..ab9d15b3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-complex.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ComplexTypesData, ComplexTypesResponses, ComplexParamsData, ComplexParamsResponses } from '../../types.gen'; + +@Injectable() +export class ApiComplexService { + constructor(private readonly client: ApiClient) { + } + public async complexTypes(options: ComplexTypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async complexParams(options: ComplexParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-default.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-default.service.gen.ts new file mode 100644 index 000000000..7d4e4716c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-default.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses } from '../../types.gen'; + +@Injectable() +export class ApiDefaultService { + constructor(private readonly client: ApiClient) { + } + public async export(options: ExportData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async patchApiVApiVersionNo+tag(options: PatchApiVbyApiVersionNoTagData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async import(options: ImportData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async foo+Wow(options: FooWowData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getApiVApiVersionSimple:operation(options: GetApiVbyApiVersionSimpleOperationData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-defaults.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-defaults.service.gen.ts new file mode 100644 index 000000000..f0e60983c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-defaults.service.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; + +@Injectable() +export class ApiDefaultsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDefaultParameters(options: CallWithDefaultParametersData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDefaultOptionalParameters(options: CallWithDefaultOptionalParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callToTestOrderOfParams(options: CallToTestOrderOfParamsData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-deprecated.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-deprecated.service.gen.ts new file mode 100644 index 000000000..0c30727d8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-deprecated.service.gen.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeprecatedCallData } from '../../types.gen'; + +@Injectable() +export class ApiDeprecatedService { + constructor(private readonly client: ApiClient) { + } + /** + * @deprecated + */ + public async deprecatedCall(options: DeprecatedCallData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-descriptions.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-descriptions.service.gen.ts new file mode 100644 index 000000000..6a8839bf8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-descriptions.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithDescriptionsData } from '../../types.gen'; + +@Injectable() +export class ApiDescriptionsService { + constructor(private readonly client: ApiClient) { + } + public async callWithDescriptions(options: CallWithDescriptionsData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-duplicate.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-duplicate.service.gen.ts new file mode 100644 index 000000000..3ae1e3458 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-duplicate.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; + +@Injectable() +export class ApiDuplicateService { + constructor(private readonly client: ApiClient) { + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName(options: DuplicateNameData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async duplicateName2(options: DuplicateName2Data): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async duplicateName3(options: DuplicateName3Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async duplicateName4(options: DuplicateName4Data): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-error.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-error.service.gen.ts new file mode 100644 index 000000000..2435ca78c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-error.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TestErrorCodeData, TestErrorCodeResponses } from '../../types.gen'; + +@Injectable() +export class ApiErrorService { + constructor(private readonly client: ApiClient) { + } + public async testErrorCode(options: TestErrorCodeData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-fileresponse.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-fileresponse.service.gen.ts new file mode 100644 index 000000000..30977163e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-fileresponse.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { FileResponseData, FileResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiFileResponseService { + constructor(private readonly client: ApiClient) { + } + public async fileResponse(options: FileResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-formdata.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-formdata.service.gen.ts new file mode 100644 index 000000000..7f0627712 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-formdata.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; + +@Injectable() +export class ApiFormDataService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionFormData(options: PostApiVbyApiVersionFormDataData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-header.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-header.service.gen.ts new file mode 100644 index 000000000..f3404da09 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-header.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResultFromHeaderData, CallWithResultFromHeaderResponses } from '../../types.gen'; + +@Injectable() +export class ApiHeaderService { + constructor(private readonly client: ApiClient) { + } + public async callWithResultFromHeader(options: CallWithResultFromHeaderData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipart.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipart.service.gen.ts new file mode 100644 index 000000000..69326948d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipart.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { MultipartResponseData, MultipartResponseResponses, MultipartRequestData } from '../../types.gen'; + +@Injectable() +export class ApiMultipartService { + constructor(private readonly client: ApiClient) { + } + public async multipartResponse(options: MultipartResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async multipartRequest(options: MultipartRequestData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags1.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags1.service.gen.ts new file mode 100644 index 000000000..903a1497b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags1.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags1Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags2.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags2.service.gen.ts new file mode 100644 index 000000000..c0f73ad6c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags2.service.gen.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyAData, DummyAResponses, DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags2Service { + constructor(private readonly client: ApiClient) { + } + public async dummyA(options: DummyAData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags3.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags3.service.gen.ts new file mode 100644 index 000000000..f56684cfd --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-multipletags3.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DummyBData, DummyBResponses } from '../../types.gen'; + +@Injectable() +export class ApiMultipleTags3Service { + constructor(private readonly client: ApiClient) { + } + public async dummyB(options: DummyBData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-nocontent.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-nocontent.service.gen.ts new file mode 100644 index 000000000..9c51f8923 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-nocontent.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses } from '../../types.gen'; + +@Injectable() +export class ApiNoContentService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" new file mode 100644 index 000000000..4e288b7dc --- /dev/null +++ "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-non-ascii-\303\246\303\270\303\245\303\246\303\270\303\245\303\266\303\264\303\252\303\252.service.gen.ts" @@ -0,0 +1,30 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from '../../types.gen'; + +@Injectable() +export class ApiNonAsciiÆøåÆøÅöôêÊService { + constructor(private readonly client: ApiClient) { + } + public async nonAsciiæøåÆøÅöôêÊ字符串(options: NonAsciiæøåÆøÅöôêÊ字符串Data): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + /** + * Login User + */ + public async putWithFormUrlEncoded(options: PutWithFormUrlEncodedData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-parameters.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-parameters.service.gen.ts new file mode 100644 index 000000000..8bf767f3c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-parameters.service.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses } from '../../types.gen'; + +@Injectable() +export class ApiParametersService { + constructor(private readonly client: ApiClient) { + } + public async deleteFoo(options: DeleteFooData3): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async callWithParameters(options: CallWithParametersData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithWeirdParameterNames(options: CallWithWeirdParameterNamesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async getCallWithOptionalParam(options: GetCallWithOptionalParamData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async postCallWithOptionalParam(options: PostCallWithOptionalParamData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-requestbody.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-requestbody.service.gen.ts new file mode 100644 index 000000000..7d3c1be6e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-requestbody.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; + +@Injectable() +export class ApiRequestBodyService { + constructor(private readonly client: ApiClient) { + } + public async postApiVApiVersionRequestBody(options: PostApiVbyApiVersionRequestBodyData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-response.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-response.service.gen.ts new file mode 100644 index 000000000..426e47705 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-response.service.gen.ts @@ -0,0 +1,37 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesResponses } from '../../types.gen'; + +@Injectable() +export class ApiResponseService { + constructor(private readonly client: ApiClient) { + } + public async callWithResponseAndNoContentResponse(options: CallWithResponseAndNoContentResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithResponse(options: CallWithResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async callWithDuplicateResponses(options: CallWithDuplicateResponsesData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async callWithResponses(options: CallWithResponsesData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-simple.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-simple.service.gen.ts new file mode 100644 index 000000000..3d9ed4cc8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-simple.service.gen.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; + +@Injectable() +export class ApiSimpleService { + constructor(private readonly client: ApiClient) { + } + public async apiVVersionODataController/$count(options: ApiVVersionODataControllerCountData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async deleteCallWithoutParametersAndResponse(options: DeleteCallWithoutParametersAndResponseData): Promise> { + return await this.client.delete(options.url, { + ...options + }); + } + public async getCallWithoutParametersAndResponse(options: GetCallWithoutParametersAndResponseData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } + public async headCallWithoutParametersAndResponse(options: HeadCallWithoutParametersAndResponseData): Promise> { + return await this.client.head(options.url, { + ...options + }); + } + public async optionsCallWithoutParametersAndResponse(options: OptionsCallWithoutParametersAndResponseData): Promise> { + return await this.client.options(options.url, { + ...options + }); + } + public async patchCallWithoutParametersAndResponse(options: PatchCallWithoutParametersAndResponseData): Promise> { + return await this.client.patch(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async postCallWithoutParametersAndResponse(options: PostCallWithoutParametersAndResponseData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } + public async putCallWithoutParametersAndResponse(options: PutCallWithoutParametersAndResponseData): Promise> { + return await this.client.put(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-types.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-types.service.gen.ts new file mode 100644 index 000000000..d993617ac --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-types.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { TypesData, TypesResponses } from '../../types.gen'; + +@Injectable() +export class ApiTypesService { + constructor(private readonly client: ApiClient) { + } + public async types(options: TypesData): Promise> { + return await this.client.get(options.url, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-upload.service.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-upload.service.gen.ts new file mode 100644 index 000000000..b967a2e05 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/services/api-upload.service.gen.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { Injectable } from '@nestjs/common'; + +import type { AxiosResponse } from 'axios'; + +import { ApiClient } from '../api-client.service.gen'; + +import type { Options, TDataShape } from '../types.gen'; + +import type { UploadFileData, UploadFileResponses } from '../../types.gen'; + +@Injectable() +export class ApiUploadService { + constructor(private readonly client: ApiClient) { + } + public async uploadFile(options: UploadFileData): Promise> { + return await this.client.post(options.url, 'body' in options ? options.body : undefined, { + ...options + }); + } +} \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/types.gen.ts new file mode 100644 index 000000000..eae7ebda9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/client/types.gen.ts @@ -0,0 +1,169 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; +import type { ModuleMetadata, FactoryProvider } from '@nestjs/common'; + +import type { Auth } from '../core/auth.gen'; +import type { + Config as CoreConfig, +} from '../core/types.gen'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; + + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Factory function to create configuration + */ + useFactory?: (...args: any[]) => ClientModuleConfig | Promise; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): 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(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + 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.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/types.gen.ts new file mode 100644 index 000000000..5bfae35c0 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/core/types.gen.ts @@ -0,0 +1,120 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export interface Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, +> { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + connect: MethodFn; + delete: MethodFn; + get: MethodFn; + getConfig: () => Config; + head: MethodFn; + options: MethodFn; + patch: MethodFn; + post: MethodFn; + put: MethodFn; + request: RequestFn; + setConfig: (config: Config) => Config; + trace: MethodFn; +} + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/index.ts new file mode 100644 index 000000000..e64537d21 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; +export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/sdk.gen.ts new file mode 100644 index 000000000..e54e0318f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client as _heyApiClient } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? _heyApiClient).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? _heyApiClient).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? _heyApiClient).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? _heyApiClient).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/types.gen.ts new file mode 100644 index 000000000..f31c9030d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-nestjs/throw-on-error-true/types.gen.ts @@ -0,0 +1,2249 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +/** + * Model with number-only name + */ +export type _400Writable = string; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaksWritable = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaksWritable = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticksWritable = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotesWritable = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashesWritable = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholdersWritable = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotesWritable = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharactersWritable = number; + +/** + * This is a simple number + */ +export type SimpleIntegerWritable = number; + +/** + * This is a simple boolean + */ +export type SimpleBooleanWritable = boolean; + +/** + * This is a simple string + */ +export type SimpleStringWritable = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串Writable = string; + +/** + * This is a simple file + */ +export type SimpleFileWritable = Blob | File; + +/** + * This is a simple string + */ +export type SimpleStringWithPatternWritable = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStringsWritable = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharactersWritable = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbersWritable = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescriptionWritable = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensionsWritable = 200 | 400 | 500; + +export type EnumWithXEnumNamesWritable = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbersWritable = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleansWritable = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStringsWritable = Array; + +/** + * This is a string dictionary + */ +export type DictionaryWithStringWritable = { + [key: string]: string; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionaryWritable = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendeskWritable = string; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +export type _3eNum1ПериодWritable = 'Bird' | 'Dog'; + +export type ConstValueWritable = 'ConstValue'; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalPropertiesWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrueWritable = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = { + [key: string]: unknown; +}; + +/** + * Some % character + */ +export type CharactersInDescriptionWritable = string; + +export type ModelWithNestedArrayEnumsDataFooWritable = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBarWritable = 'baz' | 'qux'; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type ModelWithConstantSizeArrayWritable = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArrayWritable = [ + number | string, + number | string, + number | string +]; + +export type ModelWithAnyOfConstantSizeArrayNullableWritable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ + number | ImportWritable, + number | ImportWritable +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersectWritable = [ + number & string, + number & string +]; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnusedWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponseWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2Writable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooDataWritable = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2Writable = string; + +/** + * Model with restricted keyword name + */ +export type ImportWritable = string; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2Writable = { + [key: string]: string | number; +}; + +export type OneOfAllOfIssueWritable = ((ConstValueWritable | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFooWritable; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFooWritable; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStringsWritable; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/clients.test.ts b/packages/openapi-ts-tests/main/test/clients.test.ts index af3a0b1b6..3833e2556 100644 --- a/packages/openapi-ts-tests/main/test/clients.test.ts +++ b/packages/openapi-ts-tests/main/test/clients.test.ts @@ -493,3 +493,161 @@ describe('my-client', () => { ); }); }); + +describe.only('client-nestjs', () => { + const namespace = 'clients'; + + const outputDir = path.join( + __dirname, + 'generated', + '3.1.x', + namespace, + 'client-nestjs', + ); + + const createConfig = ( + userConfig: Omit & Pick, 'input'>, + ): UserConfig => ({ + ...userConfig, + input: path.join(getSpecsPath(), '3.1.x', 'full.yaml'), + logs: { + level: 'silent', + }, + output: + typeof userConfig.output === 'string' + ? path.join(outputDir, userConfig.output) + : { + ...userConfig.output, + path: path.join(outputDir, userConfig.output.path), + }, + }); + + const scenarios = [ + { + config: createConfig({ + output: 'custom-client-name', + plugins: [ + { + clientName: 'MyApi', + name: '@hey-api/client-nestjs', + }, + ], + }), + description: 'custom client name', + }, + { + config: createConfig({ + output: 'custom-module-name', + plugins: [ + { + clientName: 'CustomClient', + moduleName: 'MyCustomModule', + name: '@hey-api/client-nestjs', + }, + ], + }), + description: 'custom module name', + }, + { + config: createConfig({ + output: 'custom-client-class-name', + plugins: [ + { + clientClassName: 'MyHttpClient', + clientName: 'TestApi', + name: '@hey-api/client-nestjs', + }, + ], + }), + description: 'custom client class name', + }, + { + config: createConfig({ + output: 'throw-on-error-true', + plugins: [ + { + name: '@hey-api/client-nestjs', + throwOnError: true, + }, + ], + }), + description: 'throw on error enabled', + }, + { + config: createConfig({ + output: 'throw-on-error-false', + plugins: [ + { + name: '@hey-api/client-nestjs', + throwOnError: false, + }, + ], + }), + description: 'throw on error disabled', + }, + { + config: createConfig({ + output: 'bundled', + plugins: [ + { + bundle: true, + name: '@hey-api/client-nestjs', + }, + ], + }), + description: 'bundled client', + }, + { + config: createConfig({ + output: 'no-bundle', + plugins: [ + { + bundle: false, + name: '@hey-api/client-nestjs', + }, + ], + }), + description: 'client without bundle', + }, + { + config: createConfig({ + output: 'custom-config-combined', + plugins: [ + { + clientClassName: 'SuperClient', + clientName: 'AdvancedApi', + moduleName: 'AdvancedApiModule', + name: '@hey-api/client-nestjs', + throwOnError: true, + }, + ], + }), + description: 'combined custom configuration', + }, + ]; + + it.each(scenarios)('$description', async ({ config }) => { + await createClient(config); + + const outputPath = + typeof config.output === 'string' ? config.output : config.output.path; + const filePaths = getFilePaths(outputPath); + + await Promise.all( + filePaths.map(async (filePath) => { + const fileContent = fs.readFileSync(filePath, 'utf-8'); + + await expect(fileContent).toMatchFileSnapshot( + path.join( + __dirname, + '__snapshots__', + '3.1.x', + namespace, + 'client-nestjs', + filePath.slice(outputDir.length + 1), + ), + ); + }), + ); + }); +}); diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index bd78319f3..e7d521540 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -111,6 +111,7 @@ "@angular/platform-browser-dynamic": "19.2.0", "@angular/router": "19.2.0", "@config/vite-base": "workspace:*", + "@nestjs/common": "11.1.6", "@types/bun": "1.2.19", "@types/cross-spawn": "6.0.6", "@types/express": "4.17.21", diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts index 884d51696..532747a14 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts @@ -1,6 +1,7 @@ import type { HeyApiClientAngularPlugin } from '../client-angular'; import type { HeyApiClientAxiosPlugin } from '../client-axios'; import type { HeyApiClientFetchPlugin } from '../client-fetch'; +import type { HeyApiClientNestjsPlugin } from '../client-nestjs'; import type { HeyApiClientNextPlugin } from '../client-next'; import type { HeyApiClientNuxtPlugin } from '../client-nuxt'; @@ -8,6 +9,7 @@ export type PluginHandler = | HeyApiClientAngularPlugin['Handler'] | HeyApiClientAxiosPlugin['Handler'] | HeyApiClientFetchPlugin['Handler'] + | HeyApiClientNestjsPlugin['Handler'] | HeyApiClientNextPlugin['Handler'] | HeyApiClientNuxtPlugin['Handler']; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/bundle-index-generator.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/bundle-index-generator.test.ts new file mode 100644 index 000000000..61c0fc139 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/bundle-index-generator.test.ts @@ -0,0 +1,203 @@ +import { describe, expect, it } from 'vitest'; + +import { generateNestjsIndex } from '../bundle-index-generator'; +import { createMockPlugin, createMockServiceGroups } from './test-helpers'; + +describe('bundle-index-generator', () => { + describe('generateNestjsIndex', () => { + it('should generate index file with default client name', () => { + const plugin = createMockPlugin(); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); // module, client, 3 services, types + }); + + it('should generate index file with custom client name', () => { + const plugin = createMockPlugin({ clientName: 'MyApi' }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); // module, client, 3 services, types + }); + + it('should generate index file with custom module name', () => { + const plugin = createMockPlugin({ + clientName: 'CustomApi', + moduleName: 'CustomApiModule', + }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); + }); + + it('should generate index file with custom client class name', () => { + const plugin = createMockPlugin({ + clientClassName: 'TestApiCustomClient', + clientName: 'TestApi', + }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); + }); + + it('should handle empty service groups', () => { + const plugin = createMockPlugin(); + const serviceGroups = new Map(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(3); // module, client, types (no services) + }); + + it('should handle single service group', () => { + const plugin = createMockPlugin({ clientName: 'SingleApi' }); + const serviceGroups = new Map(); + serviceGroups.set('pets', { + className: 'SingleApiPetsService', + tag: 'pets', + }); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(4); // module, client, 1 service, types + }); + + it('should handle many service groups', () => { + const plugin = createMockPlugin({ clientName: 'LargeApi' }); + const serviceGroups = new Map(); + + // Add multiple service groups + for (let i = 0; i < 10; i++) { + serviceGroups.set(`service${i}`, { + className: `LargeApiService${i}Service`, + tag: `service${i}`, + }); + } + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(13); // module, client, 10 services, types + }); + + it('should handle service groups with special characters in tags', () => { + const plugin = createMockPlugin({ clientName: 'SpecialApi' }); + const serviceGroups = new Map(); + + serviceGroups.set('pet-store', { + className: 'SpecialApiPetStoreService', + tag: 'pet-store', + }); + + serviceGroups.set('user_management', { + className: 'SpecialApiUserManagementService', + tag: 'user_management', + }); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); // module, client, 2 services, types + }); + + it('should handle kebab-case client names', () => { + const plugin = createMockPlugin({ clientName: 'my-awesome-api' }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); + }); + + it('should handle snake_case client names', () => { + const plugin = createMockPlugin({ clientName: 'my_awesome_api' }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); + }); + + it('should handle different output paths', () => { + const plugin = createMockPlugin({ + clientName: 'PathApi', + }); + const serviceGroups = createMockServiceGroups(); + + generateNestjsIndex({ plugin, serviceGroups }); + + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-index', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); + }); + }); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-client-generator.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-client-generator.test.ts new file mode 100644 index 000000000..631855d4b --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-client-generator.test.ts @@ -0,0 +1,262 @@ +import { describe, expect, it } from 'vitest'; + +import { generateNestjsClient } from '../nestjs-client-generator'; +import { createMockPlugin } from './test-helpers'; + +describe('nestjs-client-generator', () => { + describe('generateNestjsClient', () => { + it('should generate client with default client name', () => { + const plugin = createMockPlugin(); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('ApiClient'); + expect(result.configToken).toBe('API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); // nestjs import, axios import, types import, client class, config token export + }); + + it('should generate client with custom client name', () => { + const plugin = createMockPlugin({ clientName: 'CustomApi' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('CustomApiClient'); + expect(result.configToken).toBe('CUSTOM_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should generate client with custom client class name', () => { + const plugin = createMockPlugin({ + clientClassName: 'TestApiCustomClient', + clientName: 'TestApi', + }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('TestApiCustomClient'); + expect(result.configToken).toBe('TEST_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle kebab-case client names', () => { + const plugin = createMockPlugin({ clientName: 'my-awesome-api' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('MyAwesomeApiClient'); + expect(result.configToken).toBe('MY_AWESOME_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle snake_case client names', () => { + const plugin = createMockPlugin({ clientName: 'my_awesome_api' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('MyAwesomeApiClient'); + expect(result.configToken).toBe('MY_AWESOME_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle camelCase client names', () => { + const plugin = createMockPlugin({ clientName: 'camelCaseApi' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('CamelCaseApiClient'); + expect(result.configToken).toBe('CAMEL_CASE_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle PascalCase client names', () => { + const plugin = createMockPlugin({ clientName: 'PascalCaseApi' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('PascalCaseApiClient'); + expect(result.configToken).toBe('PASCAL_CASE_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle different output paths', () => { + const plugin = createMockPlugin({ + clientName: 'PathApi', + }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('PathApiClient'); + expect(result.configToken).toBe('PATH_API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle edge case with very long client name', () => { + const plugin = createMockPlugin({ + clientName: 'VeryLongClientNameThatExceedsNormalLength', + }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe( + 'VeryLongClientNameThatExceedsNormalLengthClient', + ); + expect(result.configToken).toBe( + 'VERY_LONG_CLIENT_NAME_THAT_EXCEEDS_NORMAL_LENGTH_CLIENT_CONFIG', + ); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle edge case with single character client name', () => { + const plugin = createMockPlugin({ clientName: 'A' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('AClient'); + expect(result.configToken).toBe('A_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle numeric client names', () => { + const plugin = createMockPlugin({ clientName: 'Api2' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('Api2Client'); + expect(result.configToken).toBe('API2_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle client names with special characters', () => { + const plugin = createMockPlugin({ clientName: 'my-api_v2.0' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('MyApiV20Client'); + expect(result.configToken).toBe('MY_API_V2_0_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle client names with numbers and underscores', () => { + const plugin = createMockPlugin({ clientName: 'test_api_v1_2_3' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('TestApiV123Client'); + expect(result.configToken).toBe('TEST_API_V1_2_3_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should preserve custom client class name over generated one', () => { + const plugin = createMockPlugin({ + clientClassName: 'CompletelyDifferentClientName', + clientName: 'DefaultApi', + }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('CompletelyDifferentClientName'); + expect(result.configToken).toBe('DEFAULT_API_CLIENT_CONFIG'); // Config token still based on clientName + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + + it('should handle empty string client name gracefully', () => { + const plugin = createMockPlugin({ clientName: '' }); + + const result = generateNestjsClient({ plugin }); + + expect(result.clientClassName).toBe('ApiClient'); + expect(result.configToken).toBe('API_CLIENT_CONFIG'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-client', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); + }); + }); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-module-generator.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-module-generator.test.ts new file mode 100644 index 000000000..73d6c5c7b --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-module-generator.test.ts @@ -0,0 +1,264 @@ +import { describe, expect, it } from 'vitest'; + +import { generateNestjsModule } from '../nestjs-module-generator'; +import { createMockPlugin, createMockServiceGroups } from './test-helpers'; + +describe('nestjs-module-generator', () => { + describe('generateNestjsModule', () => { + it('should generate module with default client name', () => { + const plugin = createMockPlugin(); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('ApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); // nestjs import, types import, client import, 3 service imports, module class + }); + + it('should generate module with custom client name', () => { + const plugin = createMockPlugin({ clientName: 'CustomApi' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('CustomApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should generate module with custom module name', () => { + const plugin = createMockPlugin({ + clientName: 'TestApi', + moduleName: 'CustomTestApiModule', + }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('CustomTestApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle empty service groups', () => { + const plugin = createMockPlugin({ clientName: 'EmptyApi' }); + const serviceGroups = new Map(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('EmptyApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(4); // nestjs import, types import, client import, module class (no service imports) + }); + + it('should handle single service group', () => { + const plugin = createMockPlugin({ clientName: 'SingleApi' }); + const serviceGroups = new Map(); + serviceGroups.set('pets', { + className: 'SingleApiPetsService', + tag: 'pets', + }); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('SingleApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(5); // nestjs import, types import, client import, 1 service import, module class + }); + + it('should handle many service groups', () => { + const plugin = createMockPlugin({ clientName: 'LargeApi' }); + const serviceGroups = new Map(); + + // Add multiple service groups + for (let i = 0; i < 5; i++) { + serviceGroups.set(`service${i}`, { + className: `LargeApiService${i}Service`, + tag: `service${i}`, + }); + } + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('LargeApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(9); // nestjs import, types import, client import, 5 service imports, module class + }); + + it('should handle service groups with special characters in tags', () => { + const plugin = createMockPlugin({ clientName: 'SpecialApi' }); + const serviceGroups = new Map(); + + serviceGroups.set('pet-store', { + className: 'SpecialApiPetStoreService', + tag: 'pet-store', + }); + + serviceGroups.set('user_management', { + className: 'SpecialApiUserManagementService', + tag: 'user_management', + }); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('SpecialApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(6); // nestjs import, types import, client import, 2 service imports, module class + }); + + it('should handle kebab-case client names', () => { + const plugin = createMockPlugin({ clientName: 'my-awesome-api' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('MyAwesomeApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle snake_case client names', () => { + const plugin = createMockPlugin({ clientName: 'my_awesome_api' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('MyAwesomeApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle different output paths', () => { + const plugin = createMockPlugin({ + clientName: 'PathApi', + }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('PathApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should generate module with camelCase client name handling', () => { + const plugin = createMockPlugin({ clientName: 'camelCaseApi' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('CamelCaseApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle PascalCase client names', () => { + const plugin = createMockPlugin({ clientName: 'PascalCaseApi' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('PascalCaseApiModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle edge case with very long client name', () => { + const plugin = createMockPlugin({ + clientName: + 'VeryLongClientNameThatExceedsNormalLengthForTestingPurposes', + }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe( + 'VeryLongClientNameThatExceedsNormalLengthForTestingPurposesModule', + ); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + + it('should handle edge case with single character client name', () => { + const plugin = createMockPlugin({ clientName: 'A' }); + const serviceGroups = createMockServiceGroups(); + + const result = generateNestjsModule({ plugin, serviceGroups }); + + expect(result).toBe('AModule'); + expect(plugin.createFile).toHaveBeenCalledWith({ + id: 'nestjs-module', + path: plugin.output, + }); + + const mockFile = plugin.createFile.mock.results[0].value; + expect(mockFile.add).toHaveBeenCalledTimes(7); + }); + }); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-service-generator.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-service-generator.test.ts new file mode 100644 index 000000000..2976e9181 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/nestjs-service-generator.test.ts @@ -0,0 +1,526 @@ +import { describe, expect, it, vi } from 'vitest'; + +import { + generateOperationMethod, + generateOperationMethodName, + generateOperationParameters, + generateOperationResponseType, + generateServiceClass, + generateServices, + groupOperationsByTags, + processServiceGroups, +} from '../nestjs-service-generator'; +import { + createMockContextWithOperations, + createMockOperations, + createMockPlugin, +} from './test-helpers'; + +describe('nestjs-service-generator', () => { + describe('generateOperationMethodName', () => { + it('should use operationId when available', () => { + const operation = { + id: 'getAllPets', + method: 'get' as const, + operationId: 'getAllPets', + path: '/pets', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('getAllPets'); + }); + + it('should generate method name from method and path when no operationId', () => { + const operation = { + id: 'getPetsSearch', + method: 'get' as const, + path: '/pets/search', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('getPetsSearch'); + }); + + it('should handle path parameters correctly', () => { + const operation = { + id: 'getPetsOwner', + method: 'get' as const, + path: '/pets/{petId}/owner/{ownerId}', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('getPetsOwner'); + }); + + it('should handle single word paths', () => { + const operation = { + id: 'postPets', + method: 'post' as const, + path: '/pets', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('postPets'); + }); + + it('should handle root path', () => { + const operation = { + id: 'get', + method: 'get' as const, + path: '/', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('get'); + }); + + it('should convert operationId to camelCase', () => { + const operation = { + id: 'getAllPets', + method: 'get' as const, + operationId: 'GetAllPets', + path: '/pets', + }; + + const result = generateOperationMethodName(operation as any); + expect(result).toBe('getAllPets'); + }); + }); + + describe('generateOperationParameters', () => { + it('should generate parameters for operation with path params', () => { + const operation = { + id: 'getPetById', + method: 'get' as const, + parameters: { + path: { + petId: { + required: true, + schema: { type: 'integer' }, + }, + }, + }, + path: '/pets/{petId}', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe('{ petId: number }'); + }); + + it('should generate parameters for operation with query params', () => { + const operation = { + id: 'getPets', + method: 'get' as const, + parameters: { + query: { + limit: { + required: false, + schema: { type: 'integer' }, + }, + offset: { + required: true, + schema: { type: 'integer' }, + }, + }, + }, + path: '/pets', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe('{ limit?: number, offset: number }'); + }); + + it('should generate parameters for operation with header params', () => { + const operation = { + id: 'getPetsWithAuth', + method: 'get' as const, + parameters: { + header: { + authorization: { + required: true, + schema: { type: 'string' }, + }, + }, + }, + path: '/pets', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe('{ authorization: string }'); + }); + + it('should generate parameters for operation with body', () => { + const operation = { + body: { + mediaType: 'application/json', + required: true, + schema: { type: 'object' as const }, + }, + id: 'createPet', + method: 'post' as const, + path: '/pets', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe('{ body: any }'); + }); + + it('should generate parameters combining all types', () => { + const operation = { + body: { + mediaType: 'application/json', + required: false, + schema: { type: 'object' as const }, + }, + id: 'updatePet', + method: 'post' as const, + parameters: { + header: { + contentType: { + required: true, + schema: { type: 'string' }, + }, + }, + path: { + petId: { + required: true, + schema: { type: 'integer' }, + }, + }, + query: { + include: { + required: false, + schema: { type: 'string' }, + }, + }, + }, + path: '/pets/{petId}', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe( + '{ petId: number, include?: string, contentType: string, body?: any }', + ); + }); + + it('should return empty string for operation with no parameters', () => { + const operation = { + id: 'healthCheck', + method: 'get' as const, + path: '/health', + }; + + const result = generateOperationParameters(operation as any); + expect(result).toBe(''); + }); + }); + + describe('generateOperationResponseType', () => { + it('should return generic response type', () => { + const operation = { + id: 'getPets', + method: 'get' as const, + path: '/pets', + }; + + const result = generateOperationResponseType(operation as any); + expect(result).toBe('Promise>'); + }); + }); + + describe('generateOperationMethod', () => { + it('should generate method with parameters', () => { + const operation = { + id: 'getPetById', + method: 'get' as const, + operationId: 'getPetById', + parameters: { + path: { + petId: { + required: true, + schema: { type: 'integer' }, + }, + }, + }, + path: '/pets/{petId}', + summary: 'Get a pet by ID', + }; + + const result = generateOperationMethod(operation as any, 'Api'); + expect(result).toContain( + 'async getPetById(options: { petId: number }): Promise>', + ); + expect(result).toContain('Get a pet by ID'); + expect(result).toContain("method: 'GET'"); + expect(result).toContain("url: '/pets/{petId}'"); + }); + + it('should generate method without parameters', () => { + const operation = { + id: 'healthCheck', + method: 'get' as const, + operationId: 'healthCheck', + path: '/health', + summary: 'Health check endpoint', + }; + + const result = generateOperationMethod(operation as any, 'Api'); + expect(result).toContain( + 'async healthCheck(): Promise>', + ); + expect(result).toContain('Health check endpoint'); + expect(result).toContain("method: 'GET'"); + expect(result).toContain("url: '/health'"); + }); + + it('should handle deprecated operations', () => { + const operation = { + deprecated: true, + id: 'legacyEndpoint', + method: 'get' as const, + operationId: 'legacyEndpoint', + path: '/legacy', + summary: 'Legacy endpoint', + }; + + const result = generateOperationMethod(operation as any, 'Api'); + expect(result).toContain( + 'async legacyEndpoint(): Promise>', + ); + expect(result).toContain('@deprecated'); + }); + }); + + describe('groupOperationsByTags', () => { + it('should group operations by tags', () => { + const operations = createMockOperations(); + + const result = groupOperationsByTags(operations as any); + + expect(result.size).toBe(3); + expect(result.has('pets')).toBe(true); + expect(result.has('users')).toBe(true); + expect(result.has('store')).toBe(true); + + const petsGroup = result.get('pets'); + expect(petsGroup?.operations).toHaveLength(3); + expect(petsGroup?.tag).toBe('pets'); + }); + + it('should handle operations without tags using default', () => { + const operations = [ + { + method: 'get' as const, + operation: { + id: 'healthCheck', + method: 'get' as const, + operationId: 'healthCheck', + path: '/health', + }, + path: '/health', + }, + ]; + + const result = groupOperationsByTags(operations as any); + + expect(result.size).toBe(1); + expect(result.has('default')).toBe(true); + + const defaultGroup = result.get('default'); + expect(defaultGroup?.operations).toHaveLength(1); + expect(defaultGroup?.tag).toBe('default'); + }); + + it('should handle operations with multiple tags', () => { + const operations = [ + { + method: 'get' as const, + operation: { + id: 'getPets', + method: 'get' as const, + operationId: 'getPets', + path: '/pets', + tags: ['pets', 'animals'], + }, + path: '/pets', + }, + ]; + + const result = groupOperationsByTags(operations as any); + + expect(result.size).toBe(2); + expect(result.has('pets')).toBe(true); + expect(result.has('animals')).toBe(true); + + const petsGroup = result.get('pets'); + const animalsGroup = result.get('animals'); + expect(petsGroup?.operations).toHaveLength(1); + expect(animalsGroup?.operations).toHaveLength(1); + }); + }); + + describe('processServiceGroups', () => { + it('should apply naming conventions to service groups', () => { + const groups = new Map([ + ['pets', { className: 'pets', operations: [], tag: 'pets' }], + ['users', { className: 'users', operations: [], tag: 'users' }], + ]); + + const result = processServiceGroups(groups, 'Api'); + + expect(result.size).toBe(2); + expect(result.get('pets')?.className).toBe('ApiPetsService'); + expect(result.get('users')?.className).toBe('ApiUsersService'); + }); + + it('should handle special characters in tags', () => { + const groups = new Map([ + [ + 'pet-store', + { className: 'pet-store', operations: [], tag: 'pet-store' }, + ], + [ + 'user_management', + { + className: 'user_management', + operations: [], + tag: 'user_management', + }, + ], + ]); + + const result = processServiceGroups(groups, 'MyApi'); + + expect(result.size).toBe(2); + expect(result.get('pet-store')?.className).toBe('MyApiPetStoreService'); + expect(result.get('user_management')?.className).toBe( + 'MyApiUserManagementService', + ); + }); + }); + + describe('generateServiceClass', () => { + it('should generate service class with operations', () => { + const group = { + className: 'ApiPetsService', + operations: [ + { + method: 'get' as const, + operation: { + id: 'getPets', + method: 'get' as const, + operationId: 'getPets', + path: '/pets', + summary: 'List all pets', + }, + path: '/pets', + }, + ], + tag: 'pets', + }; + + const result = generateServiceClass(group as any, 'Api'); + + expect(result).toContain('export class ApiPetsService'); + expect(result).toContain("import { Injectable } from '@nestjs/common'"); + expect(result).toContain("import { ApiClient } from './api-client'"); + expect(result).toContain( + 'constructor(private readonly client: ApiClient)', + ); + expect(result).toContain('async getPets()'); + expect(result).toContain('List all pets'); + }); + + it('should handle empty operations', () => { + const group = { + className: 'ApiEmptyService', + operations: [], + tag: 'empty', + }; + + const result = generateServiceClass(group as any, 'Api'); + + expect(result).toContain('export class ApiEmptyService'); + expect(result).toContain( + 'constructor(private readonly client: ApiClient)', + ); + }); + }); + + describe('generateServices', () => { + it('should generate services from plugin operations', () => { + const plugin = createMockPlugin( + { clientName: 'TestApi' }, + createMockContextWithOperations(), + ); + + // Mock the forEach method to yield operations + const operations = createMockOperations(); + plugin.forEach = vi.fn().mockImplementation((eventType, callback) => { + if (eventType === 'operation') { + operations.forEach((operationData) => { + callback({ + method: operationData.method, + operation: operationData.operation, + path: operationData.path, + type: 'operation', + }); + }); + } + }); + + const result = generateServices({ plugin }); + + expect(plugin.forEach).toHaveBeenCalledWith( + 'operation', + expect.any(Function), + ); + expect(result.size).toBe(3); // pets, users, store + expect(plugin.createFile).toHaveBeenCalledTimes(3); // One file per service group + }); + + it('should handle plugin with no operations', () => { + const plugin = createMockPlugin({ clientName: 'EmptyApi' }); + + // Mock forEach to not yield any operations + plugin.forEach = vi.fn(); + + const result = generateServices({ plugin }); + + expect(plugin.forEach).toHaveBeenCalledWith( + 'operation', + expect.any(Function), + ); + expect(result.size).toBe(0); + expect(plugin.createFile).not.toHaveBeenCalled(); + }); + + it('should use custom client name', () => { + const plugin = createMockPlugin( + { clientName: 'CustomApiClient' }, + createMockContextWithOperations(), + ); + + const operations = createMockOperations(); + plugin.forEach = vi.fn().mockImplementation((eventType, callback) => { + if (eventType === 'operation') { + operations.forEach((operationData) => { + callback({ + method: operationData.method, + operation: operationData.operation, + path: operationData.path, + type: 'operation', + }); + }); + } + }); + + const result = generateServices({ plugin }); + + expect(result.size).toBe(3); + + const petsGroup = result.get('pets'); + expect(petsGroup?.className).toBe('CustomApiClientPetsService'); + }); + }); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/test-helpers.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/test-helpers.ts new file mode 100644 index 000000000..1e76fa67c --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/__tests__/test-helpers.ts @@ -0,0 +1,258 @@ +import { vi } from 'vitest'; + +import type { HeyApiClientNestjsPlugin } from '../types'; + +/** + * Creates a mock plugin instance for testing generators + */ +export const createMockPlugin = ( + config: Partial = {}, + contextOverrides: any = {}, +): any => { + const mockContext: any = { + createFile: vi.fn().mockImplementation((file: any) => ({ + add: vi.fn(), + id: file.id, + path: file.path, + toString: vi.fn().mockReturnValue(''), + })), + ir: { + components: { + parameters: {}, + requestBodies: {}, + schemas: {}, + }, + paths: {}, + servers: [], + }, + package: { + dependencies: {}, + name: '@hey-api/openapi-ts', + version: '1.0.0', + }, + plugins: {}, + ...contextOverrides, + }; + + const defaultConfig: any = { + clientName: 'Api', + output: './generated', + throwOnError: false, + ...config, + }; + + return { + config: defaultConfig, + createFile: mockContext.createFile, + forEach: vi.fn(), + output: defaultConfig.output, + }; +}; + +/** + * Creates mock service groups for testing + */ +export const createMockServiceGroups = () => { + const serviceGroups = new Map(); + + serviceGroups.set('pets', { + className: 'ApiPetsService', + tag: 'pets', + }); + + serviceGroups.set('users', { + className: 'ApiUsersService', + tag: 'users', + }); + + serviceGroups.set('store', { + className: 'ApiStoreService', + tag: 'store', + }); + + return serviceGroups; +}; + +/** + * Creates mock operations for testing + */ +export const createMockOperations = (): Array => [ + { + method: 'get' as const, + operation: { + description: 'Returns a list of pets', + id: 'getPets', + method: 'get' as const, + operationId: 'getPets', + parameters: { + query: { + limit: { + required: false, + schema: { type: 'integer' as const }, + }, + }, + }, + path: '/pets', + responses: { + '200': { + description: 'A list of pets', + }, + }, + summary: 'List all pets', + tags: ['pets'], + }, + path: '/pets', + }, + { + method: 'post' as const, + operation: { + body: { + required: true, + }, + description: 'Creates a new pet', + id: 'createPet', + method: 'post' as const, + operationId: 'createPet', + path: '/pets', + responses: { + '201': { + description: 'Pet created', + }, + }, + summary: 'Create a pet', + tags: ['pets'], + }, + path: '/pets', + }, + { + method: 'get' as const, + operation: { + description: 'Returns a pet by ID', + id: 'getPetById', + method: 'get' as const, + operationId: 'getPetById', + parameters: { + path: { + petId: { + required: true, + schema: { type: 'integer' as const }, + }, + }, + }, + path: '/pets/{petId}', + responses: { + '200': { + description: 'Pet found', + }, + '404': { + description: 'Pet not found', + }, + }, + summary: 'Get pet by ID', + tags: ['pets'], + }, + path: '/pets/{petId}', + }, + { + method: 'get' as const, + operation: { + description: 'Returns a list of users', + id: 'getUsers', + method: 'get' as const, + operationId: 'getUsers', + parameters: { + header: { + authorization: { + required: true, + schema: { type: 'string' as const }, + }, + }, + query: { + page: { + required: false, + schema: { type: 'integer' as const }, + }, + size: { + required: false, + schema: { type: 'integer' as const }, + }, + }, + }, + path: '/users', + responses: { + '200': { + description: 'A list of users', + }, + }, + summary: 'List all users', + tags: ['users'], + }, + path: '/users', + }, + { + method: 'post' as const, + operation: { + body: { + required: true, + }, + description: 'Place an order for a pet', + id: 'placeOrder', + method: 'post' as const, + operationId: 'placeOrder', + path: '/store/orders', + responses: { + '200': { + description: 'Order placed', + }, + }, + summary: 'Place an order', + tags: ['store'], + }, + path: '/store/orders', + }, +]; + +/** + * Creates a mock context with operations + */ +export const createMockContextWithOperations = (): any => { + const operations = createMockOperations(); + const paths: any = {}; + + // Group operations by path + for (const { method, operation, path } of operations) { + if (!paths[path]) { + paths[path] = {}; + } + paths[path][method] = operation; + } + + return { + createFile: vi.fn().mockImplementation((file: any) => ({ + add: vi.fn(), + id: file.id, + path: file.path, + toString: vi.fn().mockReturnValue(''), + })), + ir: { + components: { + parameters: {}, + requestBodies: {}, + schemas: {}, + }, + paths, + servers: [ + { + description: 'Production server', + url: 'https://api.example.com/v1', + }, + ], + }, + package: { + dependencies: {}, + name: '@hey-api/openapi-ts', + version: '1.0.0', + }, + plugins: {}, + }; +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle-index-generator.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle-index-generator.ts new file mode 100644 index 000000000..eb82a9cd2 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle-index-generator.ts @@ -0,0 +1,74 @@ +import { tsc } from '../../../tsc'; +import type { HeyApiClientNestjsPlugin } from './types'; +import { + createClientClassName, + createModuleClassName, + getClientName, +} from './utils'; + +/** + * Service group information for index generation + */ +interface ServiceGroup { + className: string; + tag: string; +} + +/** + * Generates the main index.ts file that exports everything + */ +export const generateNestjsIndex = ({ + plugin, + serviceGroups, +}: { + plugin: Parameters[0]['plugin']; + serviceGroups: Map; +}) => { + const clientName = getClientName(plugin.config); + const moduleClassName = + plugin.config.moduleName || createModuleClassName(clientName); + const clientClassName = + plugin.config.clientClassName || createClientClassName(clientName); + + // Create the index file + const file = plugin.createFile({ + id: 'nestjs-index', + path: `${plugin.output}/index`, + }); + + // Create module export + const moduleExport = tsc.exportNamedDeclaration({ + exports: [moduleClassName], + module: `./${clientName.toLowerCase()}.module.gen`, + }); + file.add(moduleExport); + + // Create client export + const clientExport = tsc.exportNamedDeclaration({ + exports: [clientClassName], + module: `./${clientName.toLowerCase()}-client.service.gen`, + }); + file.add(clientExport); + + // Create service exports + for (const group of serviceGroups.values()) { + const serviceExport = tsc.exportNamedDeclaration({ + exports: [group.className], + module: `./services/${clientName.toLowerCase()}-${group.tag.toLowerCase()}.service.gen`, + }); + file.add(serviceExport); + } + + // Create type exports + const typeExport = tsc.exportNamedDeclaration({ + exports: [ + 'ClientModuleConfig', + 'ClientModuleAsyncConfig', + 'RequestOptions', + 'ApiResponse', + 'ApiError', + ], + module: './types.gen', + }); + file.add(typeExport); +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle/types.ts new file mode 100644 index 000000000..46c6ab484 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/bundle/types.ts @@ -0,0 +1,167 @@ +import type { FactoryProvider, ModuleMetadata } from '@nestjs/common'; +import type { + AxiosError, + AxiosRequestConfig, + AxiosRequestHeaders, + AxiosResponse, + CreateAxiosDefaults, +} from 'axios'; + +import type { Auth } from '../../client-core/bundle/auth'; +import type { Config as CoreConfig } from '../../client-core/bundle/types'; + +/** + * Configuration interface for NestJS modules + */ +export interface ClientModuleConfig { + /** + * Custom axios configuration options + */ + axiosConfig?: AxiosRequestConfig; + + /** + * Base URL for API requests + */ + baseUrl?: string; + + /** + * Default headers to include with requests + */ + headers?: Record; +} +export const ClientModuleConfig = Symbol('ClientModuleConfig'); + +/** + * Async configuration for NestJS modules using factory pattern + */ +export interface ClientModuleAsyncConfig { + /** + * Modules to import for dependency injection + */ + imports?: ModuleMetadata['imports']; + + /** + * Dependencies to inject into the factory function + */ + inject?: FactoryProvider['inject']; + + /** + * Configuration class to use + */ + useClass?: (...args: any[]) => ClientModuleConfig; + + /** + * Factory function to create configuration + */ + useFactory?: ( + ...args: any[] + ) => ClientModuleConfig | Promise; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +/** + * Request options interface similar to axios client + */ +export interface RequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }> { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +/** + * Options type for service method calls + */ +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, +> = OmitKeys, 'body' | 'path' | 'query' | 'url'> & + TData; + +/** + * Request result type that handles both success and error cases + */ +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/config.ts new file mode 100644 index 000000000..12facaa17 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/config.ts @@ -0,0 +1,20 @@ +import { definePluginConfig } from '../../shared/utils/config'; +import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; +import { clientPluginHandler } from './plugin'; +import type { HeyApiClientNestjsPlugin } from './types'; + +export const defaultConfig: HeyApiClientNestjsPlugin['Config'] = { + ...clientDefaultMeta, + config: { + ...clientDefaultConfig, + clientName: 'Api', + throwOnError: false, + }, + handler: clientPluginHandler as HeyApiClientNestjsPlugin['Handler'], + name: '@hey-api/client-nestjs', +}; + +/** + * Type helper for `@hey-api/client-nestjs` plugin, returns {@link Plugin.Config} object + */ +export const defineConfig = definePluginConfig(defaultConfig); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/index.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/index.ts new file mode 100644 index 000000000..27a02c103 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/index.ts @@ -0,0 +1,2 @@ +export { defaultConfig, defineConfig } from './config'; +export type { HeyApiClientNestjsPlugin } from './types'; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-client-generator.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-client-generator.ts new file mode 100644 index 000000000..cd575c291 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-client-generator.ts @@ -0,0 +1,807 @@ +import { tsc } from '../../../tsc'; +import type { HeyApiClientNestjsPlugin } from './types'; +import { + createClientClassName, + createClientConfigToken, + getClientName, +} from './utils'; + +/** + * Generates the NestJS injectable client class using TypeScript compiler API + */ +export const generateNestjsClient = ({ + plugin, +}: { + plugin: Parameters[0]['plugin']; +}) => { + const clientName = getClientName(plugin.config); + const clientClassName = + plugin.config.clientClassName || createClientClassName(clientName); + const configToken = createClientConfigToken(clientName); + + // Create the client file + const file = plugin.createFile({ + id: 'nestjs-client', + path: `${plugin.output}/${clientName.toLowerCase()}-client.service`, + }); + + // Add imports + const nestjsImport = tsc.namedImportDeclarations({ + imports: ['Injectable', 'Inject'], + module: '@nestjs/common', + }); + file.add(nestjsImport); + + const axiosImport = tsc.defaultImportDeclaration({ + module: 'axios', + name: 'axios', + }); + file.add(axiosImport); + + const axiosTypesImport = tsc.namedImportDeclarations({ + imports: [ + { asType: true, name: 'AxiosInstance' }, + { asType: true, name: 'AxiosRequestConfig' }, + { asType: true, name: 'AxiosResponse' }, + { asType: true, name: 'RawAxiosRequestHeaders' }, + ], + module: 'axios', + }); + file.add(axiosTypesImport); + + const typesImport = tsc.namedImportDeclarations({ + imports: [ + { asType: true, name: 'ClientModuleConfig' }, + { asType: true, name: 'RequestOptions' }, + ], + module: './types.gen', + }); + file.add(typesImport); + + // Create the injectable client class + const clientClass = tsc.classDeclaration({ + decorator: { + args: [], + name: 'Injectable', + }, + exportClass: true, + name: clientClassName, + nodes: [ + // Private axios instance property + tsc.propertyDeclaration({ + modifier: 'private', + name: 'axiosInstance', + type: tsc.typeReferenceNode({ typeName: 'AxiosInstance' }), + }), + + // Constructor with dependency injection + tsc.constructorDeclaration({ + parameters: [ + { + accessLevel: 'private', + decorators: [ + { + args: [configToken], + name: 'Inject', + }, + ], + isReadOnly: true, + name: 'config', + type: tsc.typeReferenceNode({ typeName: 'ClientModuleConfig' }), + }, + ], + statements: [ + // Create axios configuration + tsc.constVariable({ + expression: tsc.objectExpression({ + obj: [ + { + key: 'baseURL', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'config' }), + name: tsc.identifier({ text: 'baseUrl' }), + }), + }, + { + key: 'headers', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'config' }), + name: tsc.identifier({ text: 'headers' }), + }), + }, + { + key: 'timeout', + value: tsc.ots.number(5000), + }, + { + spread: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'config' }), + name: tsc.identifier({ text: 'axiosConfig' }), + }), + }, + ], + }), + name: 'axiosConfig', + }), + + // Initialize axios instance + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'axiosInstance' }), + }), + operator: '=', + right: tsc.callExpression({ + functionName: 'axios.create', + parameters: [tsc.identifier({ text: 'axiosConfig' })], + }), + }), + }), + ], + }), + + // Generic request method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'request', + parameters: [ + { + name: 'options', + type: tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + // Prepare axios request config following client-axios pattern + tsc.constVariable({ + expression: tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'method' }), + }), + }, + { + key: 'url', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'url' }), + }), + }, + { + key: 'headers', + value: tsc.asExpression({ + expression: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'headers' }), + }), + type: tsc.typeReferenceNode({ + typeName: 'RawAxiosRequestHeaders', + }), + }), + }, + { + key: 'params', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'query' }), + }), + }, + { + key: 'data', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'body' }), + }), + }, + { + key: 'timeout', + value: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'timeout' }), + }), + }, + ], + }), + name: 'config', + typeName: 'AxiosRequestConfig', + }), + + // Make the request and return formatted response + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'axiosInstance' }), + }), + parameters: [tsc.identifier({ text: 'config' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // GET method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'get', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'GET' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // POST method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'post', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'data', + type: tsc.typeReferenceNode({ typeName: 'any' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'body' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'POST' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + key: 'body', + value: tsc.identifier({ text: 'data' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // PUT method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'put', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'data', + type: tsc.typeReferenceNode({ typeName: 'any' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'body' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'PUT' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + key: 'body', + value: tsc.identifier({ text: 'data' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // PATCH method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'patch', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'data', + type: tsc.typeReferenceNode({ typeName: 'any' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'body' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'PATCH' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + key: 'body', + value: tsc.identifier({ text: 'data' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // DELETE method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'delete', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'DELETE' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // HEAD method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'head', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'HEAD' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + + // OPTIONS method + tsc.methodDeclaration({ + accessLevel: 'public', + name: 'options', + parameters: [ + { + name: 'url', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + name: 'options', + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ typeName: 'RequestOptions' }), + tsc.typeUnionNode({ + types: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'method' }), + }), + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: 'url' }), + }), + ], + }), + ], + typeName: 'Omit', + }), + }, + ], + returnType: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: 'T' })], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }), + statements: [ + tsc.returnStatement({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: tsc.identifier({ text: 'request' }), + }), + parameters: [ + tsc.objectExpression({ + obj: [ + { + key: 'method', + value: tsc.stringLiteral({ text: 'OPTIONS' }), + }, + { + key: 'url', + value: tsc.identifier({ text: 'url' }), + }, + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }), + ], + types: [tsc.typeReferenceNode({ typeName: 'T' })], + }), + }), + ], + types: [ + { + default: 'any', + name: 'T', + }, + ], + }), + ], + }); + + file.add(clientClass); + + // Export the config token + const configTokenExport = tsc.constVariable({ + exportConst: true, + expression: tsc.stringLiteral({ text: configToken }), + name: configToken, + }); + file.add(configTokenExport); + + return { + clientClassName, + configToken, + }; +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-module-generator.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-module-generator.ts new file mode 100644 index 000000000..ac725cc9c --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-module-generator.ts @@ -0,0 +1,256 @@ +import { tsc } from '../../../tsc'; +import type { HeyApiClientNestjsPlugin } from './types'; +import { + createClientClassName, + createClientConfigToken, + createModuleClassName, + getClientName, +} from './utils'; + +/** + * Service group information for module generation + */ +interface ServiceGroup { + className: string; + tag: string; +} + +/** + * Generates the main NestJS module that ties everything together + */ +export const generateNestjsModule = ({ + plugin, + serviceGroups, +}: { + plugin: Parameters[0]['plugin']; + serviceGroups: Map; +}) => { + const clientName = getClientName(plugin.config); + const moduleClassName = + plugin.config.moduleName || createModuleClassName(clientName); + const clientClassName = + plugin.config.clientClassName || createClientClassName(clientName); + const configToken = createClientConfigToken(clientName); + + // Create the module file + const file = plugin.createFile({ + id: 'nestjs-module', + path: `${plugin.output}/${clientName.toLowerCase()}.module`, + }); + + // Add imports + const nestjsImport = tsc.namedImportDeclarations({ + imports: ['Module', 'DynamicModule'], + module: '@nestjs/common', + }); + file.add(nestjsImport); + + const typesImport = tsc.namedImportDeclarations({ + imports: [ + { asType: true, name: 'ClientModuleConfig' }, + { asType: true, name: 'ClientModuleAsyncConfig' }, + ], + module: './types.gen', + }); + file.add(typesImport); + + const clientImport = tsc.namedImportDeclarations({ + imports: [clientClassName], + module: `./${clientName.toLowerCase()}-client.service.gen`, + }); + file.add(clientImport); + + // Add service imports + for (const group of serviceGroups.values()) { + const serviceImport = tsc.namedImportDeclarations({ + imports: [group.className], + module: `./services/${clientName.toLowerCase()}-${group.tag.toLowerCase()}.service.gen`, + }); + file.add(serviceImport); + } + + // Create providers array with all services and client + const allServices = [ + clientClassName, + ...Array.from(serviceGroups.values()).map((group) => group.className), + ]; + + // Create the forRoot static method + const forRootMethod = tsc.methodDeclaration({ + accessLevel: 'public', + isStatic: true, + name: 'forRoot', + parameters: [ + { + name: 'config', + type: tsc.typeReferenceNode({ typeName: 'ClientModuleConfig' }), + }, + ], + returnType: tsc.typeReferenceNode({ typeName: 'DynamicModule' }), + statements: [ + tsc.returnStatement({ + expression: tsc.objectExpression({ + obj: [ + { + key: 'module', + value: tsc.identifier({ text: moduleClassName }), + }, + { + key: 'providers', + value: tsc.arrayLiteralExpression({ + elements: [ + // Config provider + tsc.objectExpression({ + obj: [ + { + key: 'provide', + value: tsc.stringLiteral({ text: configToken }), + }, + { + key: 'useValue', + value: tsc.identifier({ text: 'config' }), + }, + ], + }), + // All service providers + ...allServices.map((serviceName) => + tsc.identifier({ text: serviceName }), + ), + ], + }), + }, + { + key: 'exports', + value: tsc.arrayLiteralExpression({ + elements: allServices.map((serviceName) => + tsc.identifier({ text: serviceName }), + ), + }), + }, + ], + }), + }), + ], + }); + + // Create the forRootAsync static method + const forRootAsyncMethod = tsc.methodDeclaration({ + accessLevel: 'public', + isStatic: true, + name: 'forRootAsync', + parameters: [ + { + name: 'options', + type: tsc.typeReferenceNode({ typeName: 'ClientModuleAsyncConfig' }), + }, + ], + returnType: tsc.typeReferenceNode({ typeName: 'DynamicModule' }), + statements: [ + tsc.returnStatement({ + expression: tsc.objectExpression({ + obj: [ + { + key: 'module', + value: tsc.identifier({ text: moduleClassName }), + }, + { + key: 'imports', + value: tsc.conditionalExpression({ + condition: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'imports' }), + }), + whenFalse: tsc.arrayLiteralExpression({ elements: [] }), + whenTrue: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'imports' }), + }), + }), + }, + { + key: 'providers', + value: tsc.arrayLiteralExpression({ + elements: [ + // Async config provider + tsc.objectExpression({ + obj: [ + { + key: 'provide', + value: tsc.stringLiteral({ text: configToken }), + }, + { + key: 'useFactory', + value: tsc.conditionalExpression({ + condition: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'useFactory' }), + }), + whenFalse: tsc.arrowFunction({ + parameters: [], + returnType: 'ClientModuleConfig', + statements: [ + tsc.returnStatement({ + expression: tsc.objectExpression({ obj: [] }), + }), + ], + }), + whenTrue: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'useFactory' }), + }), + }), + }, + { + key: 'inject', + value: tsc.conditionalExpression({ + condition: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'inject' }), + }), + whenFalse: tsc.arrayLiteralExpression({ + elements: [], + }), + whenTrue: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: tsc.identifier({ text: 'inject' }), + }), + }), + }, + ], + }), + // All service providers + ...allServices.map((serviceName) => + tsc.identifier({ text: serviceName }), + ), + ], + }), + }, + { + key: 'exports', + value: tsc.arrayLiteralExpression({ + elements: allServices.map((serviceName) => + tsc.identifier({ text: serviceName }), + ), + }), + }, + ], + }), + }), + ], + }); + + // Create the module class + const moduleClass = tsc.classDeclaration({ + decorator: { + args: [{}], + name: 'Module', + }, + exportClass: true, + name: moduleClassName, + nodes: [forRootMethod, forRootAsyncMethod], + }); + + file.add(moduleClass); + + return moduleClassName; +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-service-generator.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-service-generator.ts new file mode 100644 index 000000000..36914ff30 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/nestjs-service-generator.ts @@ -0,0 +1,457 @@ +import type { IR } from '../../../ir/types'; +import { tsc } from '../../../tsc'; +import { stringCase } from '../../../utils/stringCase'; +import { typesId } from '../typescript/ref'; +import type { HeyApiClientNestjsPlugin } from './types'; +import { + createClientClassName, + createServiceClassName, + getClientName, +} from './utils'; + +/** + * Represents a group of operations for a single tag + */ +interface ServiceGroup { + className: string; + operations: Array<{ + method: keyof IR.PathItemObject; + operation: IR.OperationObject; + path: string; + }>; + tag: string; +} + +/** + * Groups operations by their tags + */ +export const groupOperationsByTags = ( + operations: Array<{ + method: keyof IR.PathItemObject; + operation: IR.OperationObject; + path: string; + }>, +): Map => { + const groups = new Map(); + + for (const operationData of operations) { + const { operation } = operationData; + const tags = + operation.tags && operation.tags.length > 0 + ? operation.tags + : ['default']; + + for (const tag of tags) { + if (!groups.has(tag)) { + groups.set(tag, { + className: tag, + // Will be processed later with naming conventions + operations: [], + tag, + }); + } + + groups.get(tag)!.operations.push(operationData); + } + } + + return groups; +}; + +/** + * Generates method name for an operation in a service + */ +export const generateOperationMethodName = ( + operation: IR.OperationObject, +): string => { + // Use operationId if available, otherwise generate from method + path + if (operation.operationId) { + return stringCase({ + case: 'camelCase', + value: operation.operationId, + }); + } + + // Fallback: generate from method and path + const pathParts = operation.path + .split('/') + .filter((part) => part && !part.startsWith('{')) + .map((part) => stringCase({ case: 'PascalCase', value: part })); + + const methodName = stringCase({ case: 'camelCase', value: operation.method }); + const pathName = pathParts.join(''); + + return pathName ? `${methodName}${pathName}` : methodName; +}; +/** + * Processes service groups and applies naming conventions + */ +export const processServiceGroups = ( + groups: Map, + clientName: string, +): Map => { + const processedGroups = new Map(); + + for (const [tag, group] of groups) { + const processedGroup: ServiceGroup = { + ...group, + className: createServiceClassName(clientName, tag), + }; + processedGroups.set(tag, processedGroup); + } + + return processedGroups; +}; + +/** + * Main service generation function + */ +export const generateServices = ({ + plugin, +}: { + plugin: Parameters[0]['plugin']; +}) => { + const clientName = getClientName(plugin.config); + const operations: Array<{ + method: keyof IR.PathItemObject; + operation: IR.OperationObject; + path: string; + }> = []; + + // Collect all operations + plugin.forEach('operation', ({ method, operation, path }) => { + operations.push({ method, operation, path }); + }); + + // Group operations by tags + const serviceGroups = groupOperationsByTags(operations); + const processedGroups = processServiceGroups(serviceGroups, clientName); + + // Generate service files using proper plugin API + for (const [tag, group] of processedGroups) { + generateServiceFile({ clientName, group, plugin, tag }); + } + + return processedGroups; +}; + +/** + * Generates a single operation method with proper typing and implementation + */ +const generateOperationMethod = ( + operation: IR.OperationObject, + methodName: string, + _path: string, + plugin: Parameters[0]['plugin'], +) => { + // Generate JSDoc comment + const comments = []; + if (operation.summary) { + comments.push(operation.summary); + } + if (operation.description && operation.description !== operation.summary) { + comments.push(operation.description); + } + if (operation.deprecated) { + comments.push('@deprecated'); + } + + // Get TypeScript plugin and import types + const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; + const fileTypeScript = plugin.context.file({ id: typesId })!; + + // Get data type (request parameters) + const dataTypeId = pluginTypeScript.api.getId({ operation, type: 'data' }); + const dataTypeName = fileTypeScript.getName(dataTypeId); + + // Get response type + const responseTypeId = pluginTypeScript.api.getId({ + operation, + type: 'responses', + }); + const responseTypeName = fileTypeScript.getName(responseTypeId); + + // Create the method parameter type based on the operation + const hasParams = hasOperationParameters(operation); + + // All methods should have at least an options parameter (optional if no required params) + const parameters = hasParams + ? [ + { + name: 'options', + type: tsc.typeReferenceNode({ typeName: dataTypeName || 'unknown' }), + }, + ] + : [ + { + isOptional: true, + name: 'options', + type: tsc.typeReferenceNode({ typeName: dataTypeName || 'unknown' }), + }, + ]; + + // Generate method implementation - always pass true since we always have an options parameter now + const methodCall = generateMethodImplementation(operation, true); + + // Create return type - get 200 response or fallback to any response + const returnType = tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeReferenceNode({ + typeArguments: [ + // Use the proper response type from TypeScript plugin + responseTypeName + ? tsc.indexedAccessTypeNode({ + indexType: tsc.literalTypeNode({ + literal: tsc.ots.number(200), + }), + objectType: tsc.typeReferenceNode({ + typeName: responseTypeName, + }), + }) + : tsc.keywordTypeNode({ keyword: 'unknown' }), + ], + typeName: 'AxiosResponse', + }), + ], + typeName: 'Promise', + }); + + return tsc.methodDeclaration({ + accessLevel: 'public', + comment: comments.length > 0 ? comments : undefined, + isAsync: true, + name: methodName, + parameters, + returnType, + statements: [methodCall], + }); +}; + +/** + * Checks if an operation has parameters + */ +const hasOperationParameters = (operation: IR.OperationObject): boolean => { + const hasPath = + operation.parameters?.path && + Object.keys(operation.parameters.path).length > 0; + const hasQuery = + operation.parameters?.query && + Object.keys(operation.parameters.query).length > 0; + const hasHeader = + operation.parameters?.header && + Object.keys(operation.parameters.header).length > 0; + const hasBody = !!operation.body; + + return hasPath || hasQuery || hasHeader || hasBody; +}; + +/** + * Generates the method implementation that calls the client + */ +const generateMethodImplementation = ( + operation: IR.OperationObject, + hasParams: boolean, +) => { + const methodName = operation.method.toLowerCase(); + + // Methods that require data (POST, PUT, PATCH) + const methodsWithData = ['post', 'put', 'patch']; + const hasData = methodsWithData.includes(methodName); + + if (hasData) { + // For methods with data: post(url, data, options) + return tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: 'client', + }), + name: methodName, + }), + parameters: [ + // URL parameter - either from options or default path + hasParams + ? tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'url', + }) + : tsc.stringLiteral({ text: operation.path }), + // Data parameter - either from options.body or undefined + hasParams + ? tsc.conditionalExpression({ + condition: tsc.binaryExpression({ + left: tsc.stringLiteral({ text: 'body' }), + operator: 'in', + right: tsc.identifier({ text: 'options' }), + }), + whenFalse: tsc.identifier({ text: 'undefined' }), + whenTrue: tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'body', + }), + }) + : tsc.identifier({ text: 'undefined' }), + // Options parameter - spread options but exclude url and body + hasParams + ? tsc.objectExpression({ + obj: [ + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }) + : tsc.objectExpression({ obj: [] }), + ], + }), + }), + }); + } else { + // For methods without data: get(url, options), delete(url, options) + return tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: 'client', + }), + name: methodName, + }), + parameters: [ + // URL parameter - either from options or default path + hasParams + ? tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'url', + }) + : tsc.stringLiteral({ text: operation.path }), + // Options parameter - spread options but exclude url + hasParams + ? tsc.objectExpression({ + obj: [ + { + spread: tsc.identifier({ text: 'options' }), + }, + ], + }) + : tsc.objectExpression({ obj: [] }), + ], + }), + }), + }); + } +}; + +/** + * Generates a single service file using the TypeScript Compiler API + */ +const generateServiceFile = ({ + clientName, + group, + plugin, + tag, +}: { + clientName: string; + group: ServiceGroup; + plugin: Parameters[0]['plugin']; + tag: string; +}) => { + const clientClassName = createClientClassName(clientName); + + // Create service file + const file = plugin.createFile({ + id: `service-${tag}`, + path: `${plugin.output}/services/${clientName.toLowerCase()}-${tag.toLowerCase()}.service`, + }); + + // Add imports + const nestjsImport = tsc.namedImportDeclarations({ + imports: ['Injectable'], + module: '@nestjs/common', + }); + file.add(nestjsImport); + + const axiosImport = tsc.namedImportDeclarations({ + imports: [{ asType: true, name: 'AxiosResponse' }], + module: 'axios', + }); + file.add(axiosImport); + + const clientImport = tsc.namedImportDeclarations({ + imports: [clientClassName], + module: `../${clientName.toLowerCase()}-client.service.gen`, + }); + file.add(clientImport); + + // Import operation-specific types from TypeScript plugin + const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; + const fileTypeScript = plugin.context.file({ id: typesId })!; + const typesToImport = new Set(); + + // Collect all unique type names for this service + for (const { operation } of group.operations) { + const dataTypeId = pluginTypeScript.api.getId({ operation, type: 'data' }); + const dataTypeName = fileTypeScript.getName(dataTypeId); + if (dataTypeName) { + typesToImport.add(dataTypeName); + } + + const responseTypeId = pluginTypeScript.api.getId({ + operation, + type: 'responses', + }); + const responseTypeName = fileTypeScript.getName(responseTypeId); + if (responseTypeName) { + typesToImport.add(responseTypeName); + } + } + + // Import all the types at once + if (typesToImport.size > 0) { + const operationTypesImport = tsc.namedImportDeclarations({ + imports: Array.from(typesToImport).map((name) => ({ + asType: true, + name, + })), + module: file.relativePathToFile({ context: plugin.context, id: typesId }), + }); + file.add(operationTypesImport); + } + + // Create constructor + const constructor = tsc.constructorDeclaration({ + parameters: [ + { + accessLevel: 'private', + isReadOnly: true, + name: 'client', + type: tsc.typeReferenceNode({ typeName: clientClassName }), + }, + ], + statements: [], + }); + + // Create service methods for each operation + const methods: Array = [constructor]; + + for (const { operation, path } of group.operations) { + const methodName = generateOperationMethodName(operation); + const method = generateOperationMethod(operation, methodName, path, plugin); + methods.push(method); + } + + // Create the service class + const serviceClass = tsc.classDeclaration({ + decorator: { + args: [], + name: 'Injectable', + }, + exportClass: true, + name: group.className, + nodes: methods, + }); + + file.add(serviceClass); +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/plugin.ts new file mode 100644 index 000000000..e89e479eb --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/plugin.ts @@ -0,0 +1,42 @@ +import { createClientConfigType } from '../client-core/createClientConfig'; +import { clientId } from '../client-core/utils'; +import { generateNestjsIndex } from './bundle-index-generator'; +import { generateNestjsClient } from './nestjs-client-generator'; +import { generateNestjsModule } from './nestjs-module-generator'; +import { generateServices } from './nestjs-service-generator'; +import type { HeyApiClientNestjsPlugin } from './types'; + +export const clientPluginHandler = ({ + plugin, +}: { + plugin: Parameters[0]['plugin']; +}) => { + // Create main client file structure + plugin.createFile({ + id: clientId, + path: plugin.output, + }); + + // Create client configuration type (reuse from client-core) + createClientConfigType({ + plugin, + }); + + // Generate the injectable client wrapper + generateNestjsClient({ plugin }); + + // Generate services for each tag + const serviceGroups = generateServices({ plugin }); + + // Generate the NestJS module + generateNestjsModule({ + plugin, + serviceGroups, + }); + + // Generate the main index file + generateNestjsIndex({ + plugin, + serviceGroups, + }); +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/types.d.ts new file mode 100644 index 000000000..e70f8ad2c --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/types.d.ts @@ -0,0 +1,41 @@ +import type { DefinePlugin, Plugin } from '../../types'; +import type { Client } from '../client-core/types'; + +export type UserConfig = Plugin.Name<'@hey-api/client-nestjs'> & + Client.Config & { + /** + * Custom client class name + * @default `${clientName}Client` + */ + clientClassName?: string; + + /** + * Unique client identifier to avoid symbol conflicts when multiple + * OpenAPI clients are used in the same NestJS application. + * This will be used as a prefix for all generated classes, services, + * modules, and injection tokens. + * @default 'Api' + */ + clientName?: string; + + /** + * Custom module name + * @default `${clientName}Module` + */ + moduleName?: string; + + /** + * Custom service naming strategy + * @default (tag, clientName) => `${clientName}${PascalCase(tag)}Service` + */ + serviceNameBuilder?: (tag: string, clientName: string) => string; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: boolean; + }; + +export type HeyApiClientNestjsPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/utils.ts new file mode 100644 index 000000000..e96365d26 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nestjs/utils.ts @@ -0,0 +1,75 @@ +import { stringCase } from '../../../utils/stringCase'; + +/** + * Utility function for generating unique injection tokens + */ +export const createClientConfigToken = (clientName: string): string => { + const tokenName = stringCase({ + case: 'SCREAMING_SNAKE_CASE', + value: `${clientName}_CLIENT_CONFIG`, + }); + return tokenName; +}; + +/** + * Utility functions for consistent naming + */ +export const createClientClassName = (clientName: string): string => + `${stringCase({ case: 'PascalCase', value: clientName })}Client`; + +export const createServiceClassName = ( + clientName: string, + tag: string, +): string => { + const pascalClientName = stringCase({ + case: 'PascalCase', + value: clientName, + }); + const pascalTag = stringCase({ case: 'PascalCase', value: tag }); + return `${pascalClientName}${pascalTag}Service`; +}; + +export const createModuleClassName = (clientName: string): string => { + const pascalClientName = stringCase({ + case: 'PascalCase', + value: clientName, + }); + return `${pascalClientName}Module`; +}; + +/** + * Utility for service file names + */ +export const createServiceFileName = ( + clientName: string, + tag: string, +): string => { + // Convert to snake_case and then replace underscores with hyphens for kebab-case + const kebabClientName = stringCase({ + case: 'snake_case', + value: clientName, + }).replace(/_/g, '-'); + const kebabTag = stringCase({ case: 'snake_case', value: tag }).replace( + /_/g, + '-', + ); + return `${kebabClientName}-${kebabTag}.service.ts`; +}; + +/** + * Utility for module file names + */ +export const createModuleFileName = (clientName: string): string => { + // Convert to snake_case and then replace underscores with hyphens for kebab-case + const kebabClientName = stringCase({ + case: 'snake_case', + value: clientName, + }).replace(/_/g, '-'); + return `${kebabClientName}.module.ts`; +}; + +/** + * Get the client name from plugin config with fallback + */ +export const getClientName = (config: { clientName?: string }): string => + config.clientName || 'Api'; diff --git a/packages/openapi-ts/src/plugins/config.ts b/packages/openapi-ts/src/plugins/config.ts index 8ae31f780..2e008134c 100644 --- a/packages/openapi-ts/src/plugins/config.ts +++ b/packages/openapi-ts/src/plugins/config.ts @@ -6,6 +6,8 @@ import type { HeyApiClientAxiosPlugin } from './@hey-api/client-axios'; import { defaultConfig as heyApiClientAxios } from './@hey-api/client-axios'; import type { HeyApiClientFetchPlugin } from './@hey-api/client-fetch'; import { defaultConfig as heyApiClientFetch } from './@hey-api/client-fetch'; +import type { HeyApiClientNestjsPlugin } from './@hey-api/client-nestjs'; +import { defaultConfig as heyApiClientNestjs } from './@hey-api/client-nestjs'; import type { HeyApiClientNextPlugin } from './@hey-api/client-next'; import { defaultConfig as heyApiClientNext } from './@hey-api/client-next'; import type { HeyApiClientNuxtPlugin } from './@hey-api/client-nuxt'; @@ -53,6 +55,7 @@ export interface PluginConfigMap { '@hey-api/client-angular': HeyApiClientAngularPlugin['Types']; '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types']; '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types']; + '@hey-api/client-nestjs': HeyApiClientNestjsPlugin['Types']; '@hey-api/client-next': HeyApiClientNextPlugin['Types']; '@hey-api/client-nuxt': HeyApiClientNuxtPlugin['Types']; '@hey-api/schemas': HeyApiSchemasPlugin['Types']; @@ -82,6 +85,7 @@ export const defaultPluginConfigs: { '@hey-api/client-angular': heyApiClientAngular, '@hey-api/client-axios': heyApiClientAxios, '@hey-api/client-fetch': heyApiClientFetch, + '@hey-api/client-nestjs': heyApiClientNestjs, '@hey-api/client-next': heyApiClientNext, '@hey-api/client-nuxt': heyApiClientNuxt, '@hey-api/schemas': heyApiSchemas, diff --git a/packages/openapi-ts/src/plugins/types.d.ts b/packages/openapi-ts/src/plugins/types.d.ts index b64aec43a..6aae82f5d 100644 --- a/packages/openapi-ts/src/plugins/types.d.ts +++ b/packages/openapi-ts/src/plugins/types.d.ts @@ -10,6 +10,7 @@ export type PluginClientNames = | '@hey-api/client-angular' | '@hey-api/client-axios' | '@hey-api/client-fetch' + | '@hey-api/client-nestjs' | '@hey-api/client-next' | '@hey-api/client-nuxt' | 'legacy/angular' diff --git a/packages/openapi-ts/src/tsc/classes.ts b/packages/openapi-ts/src/tsc/classes.ts index ffb8a0abc..2abc867ee 100644 --- a/packages/openapi-ts/src/tsc/classes.ts +++ b/packages/openapi-ts/src/tsc/classes.ts @@ -62,6 +62,7 @@ export const createConstructorDeclaration = ({ * Create a class method declaration. * @param accessLevel - the access level of the method. * @param comment - comment to add to function. + * @param isAsync - if the function is async. * @param isStatic - if the function is static. * @param multiLine - if it should be multi line. * @param name - name of the method. @@ -73,6 +74,7 @@ export const createConstructorDeclaration = ({ export const createMethodDeclaration = ({ accessLevel, comment, + isAsync = false, isStatic = false, multiLine = true, name, @@ -83,6 +85,7 @@ export const createMethodDeclaration = ({ }: { accessLevel?: AccessLevel; comment?: Comments; + isAsync?: boolean; isStatic?: boolean; multiLine?: boolean; name: string; @@ -95,6 +98,10 @@ export const createMethodDeclaration = ({ ? [createModifier({ keyword: accessLevel })] : []; + if (isAsync) { + modifiers.push(createModifier({ keyword: 'async' })); + } + if (isStatic) { modifiers.push(createModifier({ keyword: 'static' })); } diff --git a/packages/openapi-ts/src/tsc/index.ts b/packages/openapi-ts/src/tsc/index.ts index 916a571a3..1fce77752 100644 --- a/packages/openapi-ts/src/tsc/index.ts +++ b/packages/openapi-ts/src/tsc/index.ts @@ -25,6 +25,7 @@ export const tsc = { conditionalExpression: types.createConditionalExpression, constVariable: module.createConstVariable, constructorDeclaration: classes.createConstructorDeclaration, + defaultImportDeclaration: module.createDefaultImportDeclaration, enumDeclaration: types.createEnumDeclaration, exportAllDeclaration: module.createExportAllDeclaration, exportNamedDeclaration: module.createNamedExportDeclarations, diff --git a/packages/openapi-ts/src/tsc/module.ts b/packages/openapi-ts/src/tsc/module.ts index a71d81a6e..65c592959 100644 --- a/packages/openapi-ts/src/tsc/module.ts +++ b/packages/openapi-ts/src/tsc/module.ts @@ -175,6 +175,33 @@ export const createConstVariable = ({ return statement; }; +/** + * Create an import declaration. Example: `import X from './y'`. + * @param name - import name + * @param module - module containing imports + * @returns ts.ImportDeclaration + */ +export const createDefaultImportDeclaration = ({ + module, + name, +}: { + module: string; + name: string; +}): ts.ImportDeclaration => { + const importClause = ts.factory.createImportClause( + false, // isTypeOnly + createIdentifier({ text: name }), // name (default import) + undefined, // namedBindings + ); + const moduleSpecifier = ots.string(module); + const statement = ts.factory.createImportDeclaration( + undefined, // modifiers + importClause, + moduleSpecifier, + ); + return statement; +}; + /** * Create a named import declaration. Example: `import { X } from './y'`. * @param imports - named exports to import diff --git a/packages/openapi-ts/src/tsc/types.ts b/packages/openapi-ts/src/tsc/types.ts index e70aaf026..9adf29dea 100644 --- a/packages/openapi-ts/src/tsc/types.ts +++ b/packages/openapi-ts/src/tsc/types.ts @@ -2,6 +2,7 @@ import ts from 'typescript'; import { escapeName } from '../utils/escape'; import { validTypescriptIdentifierRegExp } from '../utils/regexp'; +import { createCallExpression } from './module'; import { addLeadingComments, type Comments, @@ -17,6 +18,10 @@ export type AccessLevel = 'private' | 'protected' | 'public'; export type FunctionParameter = | { accessLevel?: AccessLevel; + decorators?: { + args: any[]; + name: string; + }[]; default?: any; isReadOnly?: boolean; isRequired?: boolean; @@ -214,9 +219,36 @@ export const toParameterDeclarations = ( }); } - const modifiers = parameter.accessLevel - ? [createModifier({ keyword: parameter.accessLevel })] - : []; + const modifiers: ts.ModifierLike[] = []; + + if (parameter.decorators) { + // modifiers.push(...parameter.decorators.map((decorator) => { + // return ts.factory.createDecorator( + // ts.factory.createCallExpression( + // ts.factory.createIdentifier(decorator.name), + // undefined, + // decorator.args.map((arg) => ts.factory.createIdentifier(arg)) + // ) + // ); + // })); + + modifiers.push( + ...parameter.decorators.map((decorator) => + ts.factory.createDecorator( + createCallExpression({ + functionName: decorator.name, + parameters: decorator.args + .map((arg) => toExpression({ value: arg })) + .filter(isType), + }), + ), + ), + ); + } + + if (parameter.accessLevel) { + modifiers.push(createModifier({ keyword: parameter.accessLevel })); + } if (parameter.isReadOnly) { modifiers.push(createModifier({ keyword: 'readonly' })); diff --git a/packages/openapi-ts/tsup.config.ts b/packages/openapi-ts/tsup.config.ts index 88817b911..82b8b74ce 100644 --- a/packages/openapi-ts/tsup.config.ts +++ b/packages/openapi-ts/tsup.config.ts @@ -39,6 +39,7 @@ export default defineConfig((options) => ({ 'client-axios', 'client-core', 'client-fetch', + 'client-nestjs', 'client-next', 'client-nuxt', ]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e2aa1d656..508953252 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1225,6 +1225,9 @@ importers: '@config/vite-base': specifier: workspace:* version: link:../config-vite-base + '@nestjs/common': + specifier: 11.1.6 + version: 11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1) '@types/bun': specifier: 1.2.19 version: 1.2.19(@types/react@19.0.1) @@ -1330,6 +1333,12 @@ importers: '@hey-api/openapi-ts': specifier: workspace:* version: link:../../openapi-ts + '@nestjs/common': + specifier: 11.1.6 + version: 11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1) + '@nestjs/core': + specifier: 11.1.6 + version: 11.1.6(@nestjs/common@11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2)(rxjs@7.8.1) '@pinia/colada': specifier: 0.17.2 version: 0.17.2(pinia@2.3.0(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3)))(vue@3.5.13(typescript@5.8.3)) @@ -2463,6 +2472,9 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} + '@borewit/text-codec@0.1.1': + resolution: {integrity: sha512-5L/uBxmjaCIX5h8Z+uu+kA9BQLkc/Wl06UGR5ajNRxu+/XjonB5i8JpgFMrPj3LXTCPA0pv8yxUvbUi+QthGGA==} + '@braidai/lang@1.1.2': resolution: {integrity: sha512-qBcknbBufNHlui137Hft8xauQMTZDKdophmLFv05r2eNmdIv/MlPuP4TdUknHG68UdWLgVZwgxVe735HzJNIwA==} @@ -4083,6 +4095,10 @@ packages: '@loaderkit/resolve@1.0.4': resolution: {integrity: sha512-rJzYKVcV4dxJv+vW6jlvagF8zvGxHJ2+HTr1e2qOejfmGhAApgJHl8Aog4mMszxceTRiKTTbnpgmTO1bEZHV/A==} + '@lukeed/csprng@1.1.0': + resolution: {integrity: sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==} + engines: {node: '>=8'} + '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -4236,6 +4252,37 @@ packages: '@neoconfetti/svelte@2.0.0': resolution: {integrity: sha512-n/Uu7/XmHc8w0uBci0QWBjgbRzLhfWsH8yPJ5pMaseIvzSwabXvB30nb3JjzEYNBp9uGt4eCeY7LUmxAjnJV8A==} + '@nestjs/common@11.1.6': + resolution: {integrity: sha512-krKwLLcFmeuKDqngG2N/RuZHCs2ycsKcxWIDgcm7i1lf3sQ0iG03ci+DsP/r3FcT/eJDFsIHnKtNta2LIi7PzQ==} + peerDependencies: + class-transformer: '>=0.4.1' + class-validator: '>=0.13.2' + reflect-metadata: ^0.1.12 || ^0.2.0 + rxjs: ^7.1.0 + peerDependenciesMeta: + class-transformer: + optional: true + class-validator: + optional: true + + '@nestjs/core@11.1.6': + resolution: {integrity: sha512-siWX7UDgErisW18VTeJA+x+/tpNZrJewjTBsRPF3JVxuWRuAB1kRoiJcxHgln8Lb5UY9NdvklITR84DUEXD0Cg==} + engines: {node: '>= 20'} + peerDependencies: + '@nestjs/common': ^11.0.0 + '@nestjs/microservices': ^11.0.0 + '@nestjs/platform-express': ^11.0.0 + '@nestjs/websockets': ^11.0.0 + reflect-metadata: ^0.1.12 || ^0.2.0 + rxjs: ^7.1.0 + peerDependenciesMeta: + '@nestjs/microservices': + optional: true + '@nestjs/platform-express': + optional: true + '@nestjs/websockets': + optional: true + '@netlify/binary-info@1.0.0': resolution: {integrity: sha512-4wMPu9iN3/HL97QblBsBay3E1etIciR84izI3U+4iALY+JHCrI+a2jO0qbAZ/nxKoegypYEaiiqWXylm+/zfrw==} @@ -4432,6 +4479,11 @@ packages: '@nuxt/kit': ^3.13.1 nuxi: ^3.13.1 + '@nuxt/opencollective@0.4.1': + resolution: {integrity: sha512-GXD3wy50qYbxCJ652bDrDzgMr3NFEkIS374+IgFQKkCvk9yiYcLvX2XDYr7UyQxf4wK0e+yqDYRubZ0DtOxnmQ==} + engines: {node: ^14.18.0 || >=16.10.0, npm: '>=5.10.0'} + hasBin: true + '@nuxt/schema@3.14.1592': resolution: {integrity: sha512-A1d/08ueX8stTXNkvGqnr1eEXZgvKn+vj6s7jXhZNWApUSqMgItU4VK28vrrdpKbjIPwq2SwhnGOHUYvN9HwCQ==} engines: {node: ^14.18.0 || >=16.10.0} @@ -5855,6 +5907,13 @@ packages: '@vue/composition-api': optional: true + '@tokenizer/inflate@0.2.7': + resolution: {integrity: sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg==} + engines: {node: '>=18'} + + '@tokenizer/token@0.3.0': + resolution: {integrity: sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==} + '@tsconfig/node10@1.0.11': resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} @@ -8443,6 +8502,9 @@ packages: resolution: {integrity: sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==} engines: {node: '>=6'} + fast-safe-stringify@2.1.1: + resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} + fast-uri@3.1.0: resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} @@ -8497,6 +8559,10 @@ packages: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} + file-type@21.0.0: + resolution: {integrity: sha512-ek5xNX2YBYlXhiUXui3D/BXa3LdqPmoLJ7rqEx2bKJ7EAUEfmXgW0Das7Dc6Nr9MvqaOnIqiPV0mZk/r/UpNAg==} + engines: {node: '>=20'} + file-uri-to-path@1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} @@ -9370,6 +9436,10 @@ packages: resolution: {integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==} engines: {node: '>=8'} + iterare@1.2.1: + resolution: {integrity: sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==} + engines: {node: '>=6'} + iterator.prototype@1.1.5: resolution: {integrity: sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==} engines: {node: '>= 0.4'} @@ -9649,6 +9719,10 @@ packages: resolution: {integrity: sha512-SuHqzPl7mYStna8WRotY8XX/EUZBjjv3QyKIByeCLFfC9uXT/OIHByEcA07PzbMfQAM0KYJtLgtpMRlIe5dErQ==} hasBin: true + load-esm@1.0.2: + resolution: {integrity: sha512-nVAvWk/jeyrWyXEAs84mpQCYccxRqgKY4OznLuJhJCa0XsPSfdOIr2zvBZEj3IHEHbX97jjscKRRV539bW0Gpw==} + engines: {node: '>=13.2.0'} + load-tsconfig@0.2.5: resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -12057,6 +12131,10 @@ packages: strip-literal@3.0.0: resolution: {integrity: sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==} + strtok3@10.3.4: + resolution: {integrity: sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg==} + engines: {node: '>=18'} + styled-jsx@5.1.6: resolution: {integrity: sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==} engines: {node: '>= 12.0.0'} @@ -12287,6 +12365,10 @@ packages: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} + token-types@6.1.1: + resolution: {integrity: sha512-kh9LVIWH5CnL63Ipf0jhlBIy0UsrMj/NJDfpsy1SqOXlLKEVyXXYrnFxFT1yOOYVGBSApeVnjPw/sBz5BfEjAQ==} + engines: {node: '>=14.16'} + tokenx@1.1.0: resolution: {integrity: sha512-KCjtiC2niPwTSuz4ktM82Ki5bjqBwYpssiHDsGr5BpejN/B3ksacRvrsdoxljdMIh2nCX78alnDkeemBmYUmTA==} @@ -12515,6 +12597,14 @@ packages: engines: {node: '>=0.8.0'} hasBin: true + uid@2.0.2: + resolution: {integrity: sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==} + engines: {node: '>=8'} + + uint8array-extras@1.4.1: + resolution: {integrity: sha512-+NWHrac9dvilNgme+gP4YrBSumsaMZP0fNBtXXFIf33RLLKEcBUKaQZ7ULUbS0sBfcjxIZ4V96OTRkCbM7hxpw==} + engines: {node: '>=18'} + ultrahtml@1.6.0: resolution: {integrity: sha512-R9fBn90VTJrqqLDwyMph+HGne8eqY1iPfYhPzZrvKpIfwkWZbcYlfpsb8B9dTvBfpy1/hqAD7Wi8EKfP9e8zdw==} @@ -16004,6 +16094,8 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} + '@borewit/text-codec@0.1.1': {} + '@braidai/lang@1.1.2': {} '@changesets/apply-release-plan@7.0.12': @@ -17164,6 +17256,8 @@ snapshots: dependencies: '@braidai/lang': 1.1.2 + '@lukeed/csprng@1.1.0': {} + '@manypkg/find-root@1.1.0': dependencies: '@babel/runtime': 7.28.3 @@ -17292,6 +17386,30 @@ snapshots: '@neoconfetti/svelte@2.0.0': {} + '@nestjs/common@11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1)': + dependencies: + file-type: 21.0.0 + iterare: 1.2.1 + load-esm: 1.0.2 + reflect-metadata: 0.2.2 + rxjs: 7.8.1 + tslib: 2.8.1 + uid: 2.0.2 + transitivePeerDependencies: + - supports-color + + '@nestjs/core@11.1.6(@nestjs/common@11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2)(rxjs@7.8.1)': + dependencies: + '@nestjs/common': 11.1.6(reflect-metadata@0.2.2)(rxjs@7.8.1) + '@nuxt/opencollective': 0.4.1 + fast-safe-stringify: 2.1.1 + iterare: 1.2.1 + path-to-regexp: 8.2.0 + reflect-metadata: 0.2.2 + rxjs: 7.8.1 + tslib: 2.8.1 + uid: 2.0.2 + '@netlify/binary-info@1.0.0': {} '@netlify/blobs@9.1.2': @@ -17793,6 +17911,10 @@ snapshots: - typescript - vue-tsc + '@nuxt/opencollective@0.4.1': + dependencies: + consola: 3.4.2 + '@nuxt/schema@3.14.1592(magicast@0.3.5)(rollup@3.29.5)': dependencies: c12: 2.0.1(magicast@0.3.5) @@ -19402,6 +19524,16 @@ snapshots: vue: 3.5.13(typescript@5.8.3) vue-demi: 0.14.10(vue@3.5.13(typescript@5.8.3)) + '@tokenizer/inflate@0.2.7': + dependencies: + debug: 4.4.1 + fflate: 0.8.2 + token-types: 6.1.1 + transitivePeerDependencies: + - supports-color + + '@tokenizer/token@0.3.0': {} + '@tsconfig/node10@1.0.11': {} '@tsconfig/node12@1.0.11': {} @@ -22763,6 +22895,8 @@ snapshots: fast-redact@3.5.0: {} + fast-safe-stringify@2.1.1: {} + fast-uri@3.1.0: {} fastify-openapi-glue@4.8.0: @@ -22829,6 +22963,15 @@ snapshots: dependencies: flat-cache: 4.0.1 + file-type@21.0.0: + dependencies: + '@tokenizer/inflate': 0.2.7 + strtok3: 10.3.4 + token-types: 6.1.1 + uint8array-extras: 1.4.1 + transitivePeerDependencies: + - supports-color + file-uri-to-path@1.0.0: {} fill-range@7.1.1: @@ -23769,6 +23912,8 @@ snapshots: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 + iterare@1.2.1: {} + iterator.prototype@1.1.5: dependencies: define-data-property: 1.1.4 @@ -24125,6 +24270,8 @@ snapshots: '@lmdb/lmdb-win32-x64': 3.2.6 optional: true + load-esm@1.0.2: {} + load-tsconfig@0.2.5: {} loader-runner@4.3.0: {} @@ -27314,6 +27461,10 @@ snapshots: dependencies: js-tokens: 9.0.1 + strtok3@10.3.4: + dependencies: + '@tokenizer/token': 0.3.0 + styled-jsx@5.1.6(react@19.0.0): dependencies: client-only: 0.0.1 @@ -27582,6 +27733,12 @@ snapshots: toidentifier@1.0.1: {} + token-types@6.1.1: + dependencies: + '@borewit/text-codec': 0.1.1 + '@tokenizer/token': 0.3.0 + ieee754: 1.2.1 + tokenx@1.1.0: {} toml@3.0.0: {} @@ -27804,6 +27961,12 @@ snapshots: uglify-js@3.19.3: optional: true + uid@2.0.2: + dependencies: + '@lukeed/csprng': 1.1.0 + + uint8array-extras@1.4.1: {} + ultrahtml@1.6.0: {} unbox-primitive@1.1.0: