fork of hey-api/openapi-ts because I need some additional things

Merge branch 'main' of https://github.com/hey-api/openapi-ts into feat/codegen-core

Lubos 5b1a71e9 80505002

+17485 -70
+5
.changeset/silly-apricots-exist.md
··· 1 + --- 2 + '@hey-api/codegen-core': patch 3 + --- 4 + 5 + feat: initial release
+2
docs/partials/contributors-list.md
··· 27 27 - [Jacob Cohen](https://github.com/jacobinu) 28 28 - [Jason Lee](https://github.com/LeeChSien) 29 29 - [Jianqi Pan](https://github.com/Jannchie) 30 + - [John Gozde](https://github.com/jgoz) 30 31 - [Jordan Shatford](https://github.com/jordanshatford) 31 32 - [Josh](https://github.com/josh-hemphill) 32 33 - [Joshua](https://github.com/Joshua-hypt) ··· 64 65 - [Sebastiaan Wouters](https://github.com/SebastiaanWouters) 65 66 - [Shinigami](https://github.com/Shinigami92) 66 67 - [Simen Bekkhus](https://github.com/SimenB) 68 + - [Sjoerd Scheffer](https://github.com/ixnas) 67 69 - [Stian Jensen](https://github.com/stianjensen) 68 70 - [Tran Phuc](https://github.com/Glup3) 69 71 - [Vincent Olesen](https://github.com/volesen)
+8 -2
packages/codegen-core/src/files/file.ts
··· 145 145 } 146 146 147 147 relativePathFromFile(file: Pick<ICodegenFile, 'path'>): string { 148 - let relativePath = path.relative(path.dirname(file.path), this.path); 148 + let relativePath = path.posix.relative( 149 + path.posix.dirname(file.path), 150 + this.path, 151 + ); 149 152 if (!relativePath.startsWith('.')) { 150 153 relativePath = `./${relativePath}`; 151 154 } ··· 153 156 } 154 157 155 158 relativePathToFile(file: Pick<ICodegenFile, 'path'>): string { 156 - let relativePath = path.relative(path.dirname(this.path), file.path); 159 + let relativePath = path.posix.relative( 160 + path.posix.dirname(this.path), 161 + file.path, 162 + ); 157 163 if (!relativePath.startsWith('.')) { 158 164 relativePath = `./${relativePath}`; 159 165 }
+16
packages/openapi-ts-tests/main/test/2.0.x.test.ts
··· 249 249 }, 250 250 { 251 251 config: createConfig({ 252 + input: 'enum-names-values.json', 253 + output: 'enum-names-values-typescript-const', 254 + plugins: [ 255 + { 256 + enums: { 257 + case: 'camelCase', 258 + mode: 'typescript-const', 259 + }, 260 + name: '@hey-api/typescript', 261 + }, 262 + ], 263 + }), 264 + description: 'handles TypeScript const enum modifier', 265 + }, 266 + { 267 + config: createConfig({ 252 268 input: 'exclude-deprecated.yaml', 253 269 output: 'exclude-deprecated', 254 270 parser: {
+16
packages/openapi-ts-tests/main/test/3.0.x.test.ts
··· 452 452 }, 453 453 { 454 454 config: createConfig({ 455 + input: 'enum-names-values.json', 456 + output: 'enum-names-values-typescript-const', 457 + plugins: [ 458 + { 459 + enums: { 460 + case: 'camelCase', 461 + mode: 'typescript-const', 462 + }, 463 + name: '@hey-api/typescript', 464 + }, 465 + ], 466 + }), 467 + description: 'handles TypeScript const enum modifier', 468 + }, 469 + { 470 + config: createConfig({ 455 471 input: 'enum-null.json', 456 472 output: 'enum-null', 457 473 plugins: ['@hey-api/typescript', 'valibot'],
+16
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 473 473 }, 474 474 { 475 475 config: createConfig({ 476 + input: 'enum-names-values.yaml', 477 + output: 'enum-names-values-typescript-const', 478 + plugins: [ 479 + { 480 + enums: { 481 + case: 'camelCase', 482 + mode: 'typescript-const', 483 + }, 484 + name: '@hey-api/typescript', 485 + }, 486 + ], 487 + }), 488 + description: 'handles TypeScript const enum modifier', 489 + }, 490 + { 491 + config: createConfig({ 476 492 input: 'union-types.json', 477 493 output: 'union-types', 478 494 plugins: ['@hey-api/typescript'],
+2
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+39
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export const enum _110 { 4 + _110 = '1-10', 5 + _1120 = '11-20' 6 + } 7 + 8 + export const enum MyFoo { 9 + myFoo = 'myFoo', 10 + myBar = 'myBar' 11 + } 12 + 13 + export const enum MyFoo2 { 14 + myFoo = 'MyFoo', 15 + myBar = 'MyBar' 16 + } 17 + 18 + export type Foo = 'foo' | 'bar' | '' | true | false; 19 + 20 + export const enum Numbers { 21 + _100 = 100, 22 + _200 = 200, 23 + _300 = 300, 24 + '_-100' = -100, 25 + '_-200' = -200, 26 + '_-300' = -300 27 + } 28 + 29 + export type Arrays = [ 30 + 'foo' 31 + ] | [ 32 + 'bar' 33 + ] | [ 34 + 'baz' 35 + ]; 36 + 37 + export type ClientOptions = { 38 + baseUrl: string; 39 + };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts
··· 692 692 export const ModelWithPropertiesWritableSchema = { 693 693 description: 'This is a model with one nested property', 694 694 type: 'object', 695 - required: ['required', 'requiredAndReadOnly'], 695 + required: ['required'], 696 696 properties: { 697 697 required: { 698 698 type: 'string'
+2
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+39
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export const enum _110 { 4 + _110 = '1-10', 5 + _1120 = '11-20' 6 + } 7 + 8 + export const enum MyFoo { 9 + myFoo = 'myFoo', 10 + myBar = 'myBar' 11 + } 12 + 13 + export const enum MyFoo2 { 14 + myFoo = 'MyFoo', 15 + myBar = 'MyBar' 16 + } 17 + 18 + export type Foo = 'foo' | 'bar' | null | '' | true | false; 19 + 20 + export const enum Numbers { 21 + _100 = 100, 22 + _200 = 200, 23 + _300 = 300, 24 + '_-100' = -100, 25 + '_-200' = -200, 26 + '_-300' = -300 27 + } 28 + 29 + export type Arrays = [ 30 + 'foo' 31 + ] | [ 32 + 'bar' 33 + ] | [ 34 + 'baz' 35 + ]; 36 + 37 + export type ClientOptions = { 38 + baseUrl: `${string}://${string}` | (string & {}); 39 + };
+3 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts
··· 1571 1571 1572 1572 export const ModelWithReadOnlyAndWriteOnlySchema = { 1573 1573 type: 'object', 1574 - required: ['foo', 'bar', 'baz'], 1574 + required: ['foo', 'bar'], 1575 1575 properties: { 1576 1576 foo: { 1577 1577 type: 'string' ··· 2002 2002 export const ModelWithPropertiesWritableSchema = { 2003 2003 description: 'This is a model with one nested property', 2004 2004 type: 'object', 2005 - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], 2005 + required: ['required', 'requiredAndNullable'], 2006 2006 properties: { 2007 2007 required: { 2008 2008 type: 'string' ··· 2087 2087 2088 2088 export const ModelWithReadOnlyAndWriteOnlyWritableSchema = { 2089 2089 type: 'object', 2090 - required: ['foo', 'bar', 'baz'], 2090 + required: ['foo', 'baz'], 2091 2091 properties: { 2092 2092 foo: { 2093 2093 type: 'string'
+18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ClientOptions } from './types.gen'; 4 + import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions>({ 17 + baseURL: 'http://localhost:3000/base' 18 + }));
+162
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios'; 4 + import axios from 'axios'; 5 + 6 + import { createSseClient } from '../core/serverSentEvents.gen'; 7 + import type { HttpMethod } from '../core/types.gen'; 8 + import type { Client, Config, RequestOptions } from './types.gen'; 9 + import { 10 + buildUrl, 11 + createConfig, 12 + mergeConfigs, 13 + mergeHeaders, 14 + setAuthParams, 15 + } from './utils.gen'; 16 + 17 + export const createClient = (config: Config = {}): Client => { 18 + let _config = mergeConfigs(createConfig(), config); 19 + 20 + let instance: AxiosInstance; 21 + 22 + if (_config.axios && !('Axios' in _config.axios)) { 23 + instance = _config.axios; 24 + } else { 25 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 26 + const { auth, ...configWithoutAuth } = _config; 27 + instance = axios.create(configWithoutAuth); 28 + } 29 + 30 + const getConfig = (): Config => ({ ..._config }); 31 + 32 + const setConfig = (config: Config): Config => { 33 + _config = mergeConfigs(_config, config); 34 + instance.defaults = { 35 + ...instance.defaults, 36 + ..._config, 37 + // @ts-expect-error 38 + headers: mergeHeaders(instance.defaults.headers, _config.headers), 39 + }; 40 + return getConfig(); 41 + }; 42 + 43 + const beforeRequest = async (options: RequestOptions) => { 44 + const opts = { 45 + ..._config, 46 + ...options, 47 + axios: options.axios ?? _config.axios ?? instance, 48 + headers: mergeHeaders(_config.headers, options.headers), 49 + }; 50 + 51 + if (opts.security) { 52 + await setAuthParams({ 53 + ...opts, 54 + security: opts.security, 55 + }); 56 + } 57 + 58 + if (opts.requestValidator) { 59 + await opts.requestValidator(opts); 60 + } 61 + 62 + if (opts.body && opts.bodySerializer) { 63 + opts.body = opts.bodySerializer(opts.body); 64 + } 65 + 66 + const url = buildUrl(opts); 67 + 68 + return { opts, url }; 69 + }; 70 + 71 + // @ts-expect-error 72 + const request: Client['request'] = async (options) => { 73 + // @ts-expect-error 74 + const { opts, url } = await beforeRequest(options); 75 + try { 76 + // assign Axios here for consistency with fetch 77 + const _axios = opts.axios!; 78 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 79 + const { auth, ...optsWithoutAuth } = opts; 80 + const response = await _axios({ 81 + ...optsWithoutAuth, 82 + baseURL: opts.baseURL as string, 83 + data: opts.body, 84 + headers: opts.headers as RawAxiosRequestHeaders, 85 + // let `paramsSerializer()` handle query params if it exists 86 + params: opts.paramsSerializer ? opts.query : undefined, 87 + url, 88 + }); 89 + 90 + let { data } = response; 91 + 92 + if (opts.responseType === 'json') { 93 + if (opts.responseValidator) { 94 + await opts.responseValidator(data); 95 + } 96 + 97 + if (opts.responseTransformer) { 98 + data = await opts.responseTransformer(data); 99 + } 100 + } 101 + 102 + return { 103 + ...response, 104 + data: data ?? {}, 105 + }; 106 + } catch (error) { 107 + const e = error as AxiosError; 108 + if (opts.throwOnError) { 109 + throw e; 110 + } 111 + // @ts-expect-error 112 + e.error = e.response?.data ?? {}; 113 + return e; 114 + } 115 + }; 116 + 117 + const makeMethodFn = 118 + (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 119 + request({ ...options, method }); 120 + 121 + const makeSseFn = 122 + (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 123 + const { opts, url } = await beforeRequest(options); 124 + return createSseClient({ 125 + ...opts, 126 + body: opts.body as BodyInit | null | undefined, 127 + headers: opts.headers as Record<string, string>, 128 + method, 129 + // @ts-expect-error 130 + signal: opts.signal, 131 + url, 132 + }); 133 + }; 134 + 135 + return { 136 + buildUrl, 137 + connect: makeMethodFn('CONNECT'), 138 + delete: makeMethodFn('DELETE'), 139 + get: makeMethodFn('GET'), 140 + getConfig, 141 + head: makeMethodFn('HEAD'), 142 + instance, 143 + options: makeMethodFn('OPTIONS'), 144 + patch: makeMethodFn('PATCH'), 145 + post: makeMethodFn('POST'), 146 + put: makeMethodFn('PUT'), 147 + request, 148 + setConfig, 149 + sse: { 150 + connect: makeSseFn('CONNECT'), 151 + delete: makeSseFn('DELETE'), 152 + get: makeSseFn('GET'), 153 + head: makeSseFn('HEAD'), 154 + options: makeSseFn('OPTIONS'), 155 + patch: makeSseFn('PATCH'), 156 + post: makeSseFn('POST'), 157 + put: makeSseFn('PUT'), 158 + trace: makeSseFn('TRACE'), 159 + }, 160 + trace: makeMethodFn('TRACE'), 161 + } as Client; 162 + };
+23
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { createClient } from './client.gen'; 12 + export type { 13 + Client, 14 + ClientOptions, 15 + Config, 16 + CreateClientConfig, 17 + Options, 18 + OptionsLegacyParser, 19 + RequestOptions, 20 + RequestResult, 21 + TDataShape, 22 + } from './types.gen'; 23 + export { createConfig } from './utils.gen';
+216
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + AxiosError, 5 + AxiosInstance, 6 + AxiosRequestHeaders, 7 + AxiosResponse, 8 + AxiosStatic, 9 + CreateAxiosDefaults, 10 + } from 'axios'; 11 + 12 + import type { Auth } from '../core/auth.gen'; 13 + import type { 14 + ServerSentEventsOptions, 15 + ServerSentEventsResult, 16 + } from '../core/serverSentEvents.gen'; 17 + import type { 18 + Client as CoreClient, 19 + Config as CoreConfig, 20 + } from '../core/types.gen'; 21 + 22 + export interface Config<T extends ClientOptions = ClientOptions> 23 + extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>, 24 + CoreConfig { 25 + /** 26 + * Axios implementation. You can use this option to provide either an 27 + * `AxiosStatic` or an `AxiosInstance`. 28 + * 29 + * @default axios 30 + */ 31 + axios?: AxiosStatic | AxiosInstance; 32 + /** 33 + * Base URL for all requests made by this client. 34 + */ 35 + baseURL?: T['baseURL']; 36 + /** 37 + * An object containing any HTTP headers that you want to pre-populate your 38 + * `Headers` object with. 39 + * 40 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 41 + */ 42 + headers?: 43 + | AxiosRequestHeaders 44 + | Record< 45 + string, 46 + | string 47 + | number 48 + | boolean 49 + | (string | number | boolean)[] 50 + | null 51 + | undefined 52 + | unknown 53 + >; 54 + /** 55 + * Throw an error instead of returning it in the response? 56 + * 57 + * @default false 58 + */ 59 + throwOnError?: T['throwOnError']; 60 + } 61 + 62 + export interface RequestOptions< 63 + TData = unknown, 64 + ThrowOnError extends boolean = boolean, 65 + Url extends string = string, 66 + > extends Config<{ 67 + throwOnError: ThrowOnError; 68 + }>, 69 + Pick< 70 + ServerSentEventsOptions<TData>, 71 + | 'onSseError' 72 + | 'onSseEvent' 73 + | 'sseDefaultRetryDelay' 74 + | 'sseMaxRetryAttempts' 75 + | 'sseMaxRetryDelay' 76 + > { 77 + /** 78 + * Any body that you want to add to your request. 79 + * 80 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 81 + */ 82 + body?: unknown; 83 + path?: Record<string, unknown>; 84 + query?: Record<string, unknown>; 85 + /** 86 + * Security mechanism(s) to use for the request. 87 + */ 88 + security?: ReadonlyArray<Auth>; 89 + url: Url; 90 + } 91 + 92 + export interface ClientOptions { 93 + baseURL?: string; 94 + throwOnError?: boolean; 95 + } 96 + 97 + export type RequestResult< 98 + TData = unknown, 99 + TError = unknown, 100 + ThrowOnError extends boolean = boolean, 101 + > = ThrowOnError extends true 102 + ? Promise< 103 + AxiosResponse< 104 + TData extends Record<string, unknown> ? TData[keyof TData] : TData 105 + > 106 + > 107 + : Promise< 108 + | (AxiosResponse< 109 + TData extends Record<string, unknown> ? TData[keyof TData] : TData 110 + > & { error: undefined }) 111 + | (AxiosError< 112 + TError extends Record<string, unknown> ? TError[keyof TError] : TError 113 + > & { 114 + data: undefined; 115 + error: TError extends Record<string, unknown> 116 + ? TError[keyof TError] 117 + : TError; 118 + }) 119 + >; 120 + 121 + type MethodFn = < 122 + TData = unknown, 123 + TError = unknown, 124 + ThrowOnError extends boolean = false, 125 + >( 126 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>, 127 + ) => RequestResult<TData, TError, ThrowOnError>; 128 + 129 + type SseFn = < 130 + TData = unknown, 131 + TError = unknown, 132 + ThrowOnError extends boolean = false, 133 + >( 134 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>, 135 + ) => Promise<ServerSentEventsResult<TData, TError>>; 136 + 137 + type RequestFn = < 138 + TData = unknown, 139 + TError = unknown, 140 + ThrowOnError extends boolean = false, 141 + >( 142 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> & 143 + Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>, 144 + ) => RequestResult<TData, TError, ThrowOnError>; 145 + 146 + type BuildUrlFn = < 147 + TData extends { 148 + body?: unknown; 149 + path?: Record<string, unknown>; 150 + query?: Record<string, unknown>; 151 + url: string; 152 + }, 153 + >( 154 + options: Pick<TData, 'url'> & Omit<Options<TData>, 'axios'>, 155 + ) => string; 156 + 157 + export type Client = CoreClient< 158 + RequestFn, 159 + Config, 160 + MethodFn, 161 + BuildUrlFn, 162 + SseFn 163 + > & { 164 + instance: AxiosInstance; 165 + }; 166 + 167 + /** 168 + * The `createClientConfig()` function will be called on client initialization 169 + * and the returned object will become the client's initial configuration. 170 + * 171 + * You may want to initialize your client this way instead of calling 172 + * `setConfig()`. This is useful for example if you're using Next.js 173 + * to ensure your client always has the correct values. 174 + */ 175 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 176 + override?: Config<ClientOptions & T>, 177 + ) => Config<Required<ClientOptions> & T>; 178 + 179 + export interface TDataShape { 180 + body?: unknown; 181 + headers?: unknown; 182 + path?: unknown; 183 + query?: unknown; 184 + url: string; 185 + } 186 + 187 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 188 + 189 + export type Options< 190 + TData extends TDataShape = TDataShape, 191 + ThrowOnError extends boolean = boolean, 192 + TResponse = unknown, 193 + > = OmitKeys< 194 + RequestOptions<TResponse, ThrowOnError>, 195 + 'body' | 'path' | 'query' | 'url' 196 + > & 197 + Omit<TData, 'url'>; 198 + 199 + export type OptionsLegacyParser< 200 + TData = unknown, 201 + ThrowOnError extends boolean = boolean, 202 + > = TData extends { body?: any } 203 + ? TData extends { headers?: any } 204 + ? OmitKeys< 205 + RequestOptions<unknown, ThrowOnError>, 206 + 'body' | 'headers' | 'url' 207 + > & 208 + TData 209 + : OmitKeys<RequestOptions<unknown, ThrowOnError>, 'body' | 'url'> & 210 + TData & 211 + Pick<RequestOptions<unknown, ThrowOnError>, 'headers'> 212 + : TData extends { headers?: any } 213 + ? OmitKeys<RequestOptions<unknown, ThrowOnError>, 'headers' | 'url'> & 214 + TData & 215 + Pick<RequestOptions<unknown, ThrowOnError>, 'body'> 216 + : OmitKeys<RequestOptions<unknown, ThrowOnError>, 'url'> & TData;
+204
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + import { 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from '../core/pathSerializer.gen'; 10 + import { getUrl } from '../core/utils.gen'; 11 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 12 + 13 + export const createQuerySerializer = <T = unknown>({ 14 + allowReserved, 15 + array, 16 + object, 17 + }: QuerySerializerOptions = {}) => { 18 + const querySerializer = (queryParams: T) => { 19 + const search: string[] = []; 20 + if (queryParams && typeof queryParams === 'object') { 21 + for (const name in queryParams) { 22 + const value = queryParams[name]; 23 + 24 + if (value === undefined || value === null) { 25 + continue; 26 + } 27 + 28 + if (Array.isArray(value)) { 29 + const serializedArray = serializeArrayParam({ 30 + allowReserved, 31 + explode: true, 32 + name, 33 + style: 'form', 34 + value, 35 + ...array, 36 + }); 37 + if (serializedArray) search.push(serializedArray); 38 + } else if (typeof value === 'object') { 39 + const serializedObject = serializeObjectParam({ 40 + allowReserved, 41 + explode: true, 42 + name, 43 + style: 'deepObject', 44 + value: value as Record<string, unknown>, 45 + ...object, 46 + }); 47 + if (serializedObject) search.push(serializedObject); 48 + } else { 49 + const serializedPrimitive = serializePrimitiveParam({ 50 + allowReserved, 51 + name, 52 + value: value as string, 53 + }); 54 + if (serializedPrimitive) search.push(serializedPrimitive); 55 + } 56 + } 57 + } 58 + return search.join('&'); 59 + }; 60 + return querySerializer; 61 + }; 62 + 63 + const checkForExistence = ( 64 + options: Pick<RequestOptions, 'auth' | 'query'> & { 65 + headers: Record<any, unknown>; 66 + }, 67 + name?: string, 68 + ): boolean => { 69 + if (!name) { 70 + return false; 71 + } 72 + if (name in options.headers || options.query?.[name]) { 73 + return true; 74 + } 75 + if ( 76 + 'Cookie' in options.headers && 77 + options.headers['Cookie'] && 78 + typeof options.headers['Cookie'] === 'string' 79 + ) { 80 + return options.headers['Cookie'].includes(`${name}=`); 81 + } 82 + return false; 83 + }; 84 + 85 + export const setAuthParams = async ({ 86 + security, 87 + ...options 88 + }: Pick<Required<RequestOptions>, 'security'> & 89 + Pick<RequestOptions, 'auth' | 'query'> & { 90 + headers: Record<any, unknown>; 91 + }) => { 92 + for (const auth of security) { 93 + if (checkForExistence(options, auth.name)) { 94 + continue; 95 + } 96 + const token = await getAuthToken(auth, options.auth); 97 + 98 + if (!token) { 99 + continue; 100 + } 101 + 102 + const name = auth.name ?? 'Authorization'; 103 + 104 + switch (auth.in) { 105 + case 'query': 106 + if (!options.query) { 107 + options.query = {}; 108 + } 109 + options.query[name] = token; 110 + break; 111 + case 'cookie': { 112 + const value = `${name}=${token}`; 113 + if ('Cookie' in options.headers && options.headers['Cookie']) { 114 + options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`; 115 + } else { 116 + options.headers['Cookie'] = value; 117 + } 118 + break; 119 + } 120 + case 'header': 121 + default: 122 + options.headers[name] = token; 123 + break; 124 + } 125 + } 126 + }; 127 + 128 + export const buildUrl: Client['buildUrl'] = (options) => 129 + getUrl({ 130 + baseUrl: options.baseURL as string, 131 + path: options.path, 132 + // let `paramsSerializer()` handle query params if it exists 133 + query: !options.paramsSerializer ? options.query : undefined, 134 + querySerializer: 135 + typeof options.querySerializer === 'function' 136 + ? options.querySerializer 137 + : createQuerySerializer(options.querySerializer), 138 + url: options.url, 139 + }); 140 + 141 + export const mergeConfigs = (a: Config, b: Config): Config => { 142 + const config = { ...a, ...b }; 143 + config.headers = mergeHeaders(a.headers, b.headers); 144 + return config; 145 + }; 146 + 147 + /** 148 + * Special Axios headers keywords allowing to set headers by request method. 149 + */ 150 + export const axiosHeadersKeywords = [ 151 + 'common', 152 + 'delete', 153 + 'get', 154 + 'head', 155 + 'patch', 156 + 'post', 157 + 'put', 158 + ] as const; 159 + 160 + export const mergeHeaders = ( 161 + ...headers: Array<Required<Config>['headers'] | undefined> 162 + ): Record<any, unknown> => { 163 + const mergedHeaders: Record<any, unknown> = {}; 164 + for (const header of headers) { 165 + if (!header || typeof header !== 'object') { 166 + continue; 167 + } 168 + 169 + const iterator = Object.entries(header); 170 + 171 + for (const [key, value] of iterator) { 172 + if ( 173 + axiosHeadersKeywords.includes( 174 + key as (typeof axiosHeadersKeywords)[number], 175 + ) && 176 + typeof value === 'object' 177 + ) { 178 + mergedHeaders[key] = { 179 + ...(mergedHeaders[key] as Record<any, unknown>), 180 + ...value, 181 + }; 182 + } else if (value === null) { 183 + delete mergedHeaders[key]; 184 + } else if (Array.isArray(value)) { 185 + for (const v of value) { 186 + // @ts-expect-error 187 + mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string]; 188 + } 189 + } else if (value !== undefined) { 190 + // assume object headers are meant to be JSON stringified, i.e. their 191 + // content value in OpenAPI specification is 'application/json' 192 + mergedHeaders[key] = 193 + typeof value === 'object' ? JSON.stringify(value) : (value as string); 194 + } 195 + } 196 + } 197 + return mergedHeaders; 198 + }; 199 + 200 + export const createConfig = <T extends ClientOptions = ClientOptions>( 201 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 202 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 203 + ...override, 204 + });
+42
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = 27 + typeof callback === 'function' ? await callback(auth) : callback; 28 + 29 + if (!token) { 30 + return; 31 + } 32 + 33 + if (auth.scheme === 'bearer') { 34 + return `Bearer ${token}`; 35 + } 36 + 37 + if (auth.scheme === 'basic') { 38 + return `Basic ${btoa(token)}`; 39 + } 40 + 41 + return token; 42 + };
+92
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + ArrayStyle, 5 + ObjectStyle, 6 + SerializerOptions, 7 + } from './pathSerializer.gen'; 8 + 9 + export type QuerySerializer = (query: Record<string, unknown>) => string; 10 + 11 + export type BodySerializer = (body: any) => any; 12 + 13 + export interface QuerySerializerOptions { 14 + allowReserved?: boolean; 15 + array?: SerializerOptions<ArrayStyle>; 16 + object?: SerializerOptions<ObjectStyle>; 17 + } 18 + 19 + const serializeFormDataPair = ( 20 + data: FormData, 21 + key: string, 22 + value: unknown, 23 + ): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = ( 34 + data: URLSearchParams, 35 + key: string, 36 + value: unknown, 37 + ): void => { 38 + if (typeof value === 'string') { 39 + data.append(key, value); 40 + } else { 41 + data.append(key, JSON.stringify(value)); 42 + } 43 + }; 44 + 45 + export const formDataBodySerializer = { 46 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 47 + body: T, 48 + ): FormData => { 49 + const data = new FormData(); 50 + 51 + Object.entries(body).forEach(([key, value]) => { 52 + if (value === undefined || value === null) { 53 + return; 54 + } 55 + if (Array.isArray(value)) { 56 + value.forEach((v) => serializeFormDataPair(data, key, v)); 57 + } else { 58 + serializeFormDataPair(data, key, value); 59 + } 60 + }); 61 + 62 + return data; 63 + }, 64 + }; 65 + 66 + export const jsonBodySerializer = { 67 + bodySerializer: <T>(body: T): string => 68 + JSON.stringify(body, (_key, value) => 69 + typeof value === 'bigint' ? value.toString() : value, 70 + ), 71 + }; 72 + 73 + export const urlSearchParamsBodySerializer = { 74 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 75 + body: T, 76 + ): string => { 77 + const data = new URLSearchParams(); 78 + 79 + Object.entries(body).forEach(([key, value]) => { 80 + if (value === undefined || value === null) { 81 + return; 82 + } 83 + if (Array.isArray(value)) { 84 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 85 + } else { 86 + serializeUrlSearchParamsPair(data, key, value); 87 + } 88 + }); 89 + 90 + return data.toString(); 91 + }, 92 + };
+153
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + }; 26 + 27 + export interface Fields { 28 + allowExtra?: Partial<Record<Slot, boolean>>; 29 + args?: ReadonlyArray<Field>; 30 + } 31 + 32 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 33 + 34 + const extraPrefixesMap: Record<string, Slot> = { 35 + $body_: 'body', 36 + $headers_: 'headers', 37 + $path_: 'path', 38 + $query_: 'query', 39 + }; 40 + const extraPrefixes = Object.entries(extraPrefixesMap); 41 + 42 + type KeyMap = Map< 43 + string, 44 + { 45 + in: Slot; 46 + map?: string; 47 + } 48 + >; 49 + 50 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 51 + if (!map) { 52 + map = new Map(); 53 + } 54 + 55 + for (const config of fields) { 56 + if ('in' in config) { 57 + if (config.key) { 58 + map.set(config.key, { 59 + in: config.in, 60 + map: config.map, 61 + }); 62 + } 63 + } else if (config.args) { 64 + buildKeyMap(config.args, map); 65 + } 66 + } 67 + 68 + return map; 69 + }; 70 + 71 + interface Params { 72 + body: unknown; 73 + headers: Record<string, unknown>; 74 + path: Record<string, unknown>; 75 + query: Record<string, unknown>; 76 + } 77 + 78 + const stripEmptySlots = (params: Params) => { 79 + for (const [slot, value] of Object.entries(params)) { 80 + if (value && typeof value === 'object' && !Object.keys(value).length) { 81 + delete params[slot as Slot]; 82 + } 83 + } 84 + }; 85 + 86 + export const buildClientParams = ( 87 + args: ReadonlyArray<unknown>, 88 + fields: FieldsConfig, 89 + ) => { 90 + const params: Params = { 91 + body: {}, 92 + headers: {}, 93 + path: {}, 94 + query: {}, 95 + }; 96 + 97 + const map = buildKeyMap(fields); 98 + 99 + let config: FieldsConfig[number] | undefined; 100 + 101 + for (const [index, arg] of args.entries()) { 102 + if (fields[index]) { 103 + config = fields[index]; 104 + } 105 + 106 + if (!config) { 107 + continue; 108 + } 109 + 110 + if ('in' in config) { 111 + if (config.key) { 112 + const field = map.get(config.key)!; 113 + const name = field.map || config.key; 114 + (params[field.in] as Record<string, unknown>)[name] = arg; 115 + } else { 116 + params.body = arg; 117 + } 118 + } else { 119 + for (const [key, value] of Object.entries(arg ?? {})) { 120 + const field = map.get(key); 121 + 122 + if (field) { 123 + const name = field.map || key; 124 + (params[field.in] as Record<string, unknown>)[name] = value; 125 + } else { 126 + const extra = extraPrefixes.find(([prefix]) => 127 + key.startsWith(prefix), 128 + ); 129 + 130 + if (extra) { 131 + const [prefix, slot] = extra; 132 + (params[slot] as Record<string, unknown>)[ 133 + key.slice(prefix.length) 134 + ] = value; 135 + } else { 136 + for (const [slot, allowed] of Object.entries( 137 + config.allowExtra ?? {}, 138 + )) { 139 + if (allowed) { 140 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 141 + break; 142 + } 143 + } 144 + } 145 + } 146 + } 147 + } 148 + } 149 + 150 + stripEmptySlots(params); 151 + 152 + return params; 153 + };
+181
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> 4 + extends SerializePrimitiveOptions, 5 + SerializerOptions<T> {} 6 + 7 + interface SerializePrimitiveOptions { 8 + allowReserved?: boolean; 9 + name: string; 10 + } 11 + 12 + export interface SerializerOptions<T> { 13 + /** 14 + * @default true 15 + */ 16 + explode: boolean; 17 + style: T; 18 + } 19 + 20 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 21 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 22 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 23 + export type ObjectStyle = 'form' | 'deepObject'; 24 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 25 + 26 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 27 + value: string; 28 + } 29 + 30 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 31 + switch (style) { 32 + case 'label': 33 + return '.'; 34 + case 'matrix': 35 + return ';'; 36 + case 'simple': 37 + return ','; 38 + default: 39 + return '&'; 40 + } 41 + }; 42 + 43 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 44 + switch (style) { 45 + case 'form': 46 + return ','; 47 + case 'pipeDelimited': 48 + return '|'; 49 + case 'spaceDelimited': 50 + return '%20'; 51 + default: 52 + return ','; 53 + } 54 + }; 55 + 56 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 57 + switch (style) { 58 + case 'label': 59 + return '.'; 60 + case 'matrix': 61 + return ';'; 62 + case 'simple': 63 + return ','; 64 + default: 65 + return '&'; 66 + } 67 + }; 68 + 69 + export const serializeArrayParam = ({ 70 + allowReserved, 71 + explode, 72 + name, 73 + style, 74 + value, 75 + }: SerializeOptions<ArraySeparatorStyle> & { 76 + value: unknown[]; 77 + }) => { 78 + if (!explode) { 79 + const joinedValues = ( 80 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 81 + ).join(separatorArrayNoExplode(style)); 82 + switch (style) { 83 + case 'label': 84 + return `.${joinedValues}`; 85 + case 'matrix': 86 + return `;${name}=${joinedValues}`; 87 + case 'simple': 88 + return joinedValues; 89 + default: 90 + return `${name}=${joinedValues}`; 91 + } 92 + } 93 + 94 + const separator = separatorArrayExplode(style); 95 + const joinedValues = value 96 + .map((v) => { 97 + if (style === 'label' || style === 'simple') { 98 + return allowReserved ? v : encodeURIComponent(v as string); 99 + } 100 + 101 + return serializePrimitiveParam({ 102 + allowReserved, 103 + name, 104 + value: v as string, 105 + }); 106 + }) 107 + .join(separator); 108 + return style === 'label' || style === 'matrix' 109 + ? separator + joinedValues 110 + : joinedValues; 111 + }; 112 + 113 + export const serializePrimitiveParam = ({ 114 + allowReserved, 115 + name, 116 + value, 117 + }: SerializePrimitiveParam) => { 118 + if (value === undefined || value === null) { 119 + return ''; 120 + } 121 + 122 + if (typeof value === 'object') { 123 + throw new Error( 124 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 125 + ); 126 + } 127 + 128 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 129 + }; 130 + 131 + export const serializeObjectParam = ({ 132 + allowReserved, 133 + explode, 134 + name, 135 + style, 136 + value, 137 + valueOnly, 138 + }: SerializeOptions<ObjectSeparatorStyle> & { 139 + value: Record<string, unknown> | Date; 140 + valueOnly?: boolean; 141 + }) => { 142 + if (value instanceof Date) { 143 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 144 + } 145 + 146 + if (style !== 'deepObject' && !explode) { 147 + let values: string[] = []; 148 + Object.entries(value).forEach(([key, v]) => { 149 + values = [ 150 + ...values, 151 + key, 152 + allowReserved ? (v as string) : encodeURIComponent(v as string), 153 + ]; 154 + }); 155 + const joinedValues = values.join(','); 156 + switch (style) { 157 + case 'form': 158 + return `${name}=${joinedValues}`; 159 + case 'label': 160 + return `.${joinedValues}`; 161 + case 'matrix': 162 + return `;${name}=${joinedValues}`; 163 + default: 164 + return joinedValues; 165 + } 166 + } 167 + 168 + const separator = separatorObjectExplode(style); 169 + const joinedValues = Object.entries(value) 170 + .map(([key, v]) => 171 + serializePrimitiveParam({ 172 + allowReserved, 173 + name: style === 'deepObject' ? `${name}[${key}]` : key, 174 + value: v as string, 175 + }), 176 + ) 177 + .join(separator); 178 + return style === 'label' || style === 'matrix' 179 + ? separator + joinedValues 180 + : joinedValues; 181 + };
+264
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit< 6 + RequestInit, 7 + 'method' 8 + > & 9 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 + /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 22 + * Callback invoked when a network or parsing error occurs during streaming. 23 + * 24 + * This option applies only if the endpoint returns a stream of events. 25 + * 26 + * @param error The error that occurred. 27 + */ 28 + onSseError?: (error: unknown) => void; 29 + /** 30 + * Callback invoked when an event is streamed from the server. 31 + * 32 + * This option applies only if the endpoint returns a stream of events. 33 + * 34 + * @param event Event streamed from the server. 35 + * @returns Nothing (void). 36 + */ 37 + onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 39 + /** 40 + * Default retry delay in milliseconds. 41 + * 42 + * This option applies only if the endpoint returns a stream of events. 43 + * 44 + * @default 3000 45 + */ 46 + sseDefaultRetryDelay?: number; 47 + /** 48 + * Maximum number of retry attempts before giving up. 49 + */ 50 + sseMaxRetryAttempts?: number; 51 + /** 52 + * Maximum retry delay in milliseconds. 53 + * 54 + * Applies only when exponential backoff is used. 55 + * 56 + * This option applies only if the endpoint returns a stream of events. 57 + * 58 + * @default 30000 59 + */ 60 + sseMaxRetryDelay?: number; 61 + /** 62 + * Optional sleep function for retry backoff. 63 + * 64 + * Defaults to using `setTimeout`. 65 + */ 66 + sseSleepFn?: (ms: number) => Promise<void>; 67 + url: string; 68 + }; 69 + 70 + export interface StreamEvent<TData = unknown> { 71 + data: TData; 72 + event?: string; 73 + id?: string; 74 + retry?: number; 75 + } 76 + 77 + export type ServerSentEventsResult< 78 + TData = unknown, 79 + TReturn = void, 80 + TNext = unknown, 81 + > = { 82 + stream: AsyncGenerator< 83 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 84 + TReturn, 85 + TNext 86 + >; 87 + }; 88 + 89 + export const createSseClient = <TData = unknown>({ 90 + onRequest, 91 + onSseError, 92 + onSseEvent, 93 + responseTransformer, 94 + responseValidator, 95 + sseDefaultRetryDelay, 96 + sseMaxRetryAttempts, 97 + sseMaxRetryDelay, 98 + sseSleepFn, 99 + url, 100 + ...options 101 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 102 + let lastEventId: string | undefined; 103 + 104 + const sleep = 105 + sseSleepFn ?? 106 + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 107 + 108 + const createStream = async function* () { 109 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 110 + let attempt = 0; 111 + const signal = options.signal ?? new AbortController().signal; 112 + 113 + while (true) { 114 + if (signal.aborted) break; 115 + 116 + attempt++; 117 + 118 + const headers = 119 + options.headers instanceof Headers 120 + ? options.headers 121 + : new Headers(options.headers as Record<string, string> | undefined); 122 + 123 + if (lastEventId !== undefined) { 124 + headers.set('Last-Event-ID', lastEventId); 125 + } 126 + 127 + try { 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 143 + 144 + if (!response.ok) 145 + throw new Error( 146 + `SSE failed: ${response.status} ${response.statusText}`, 147 + ); 148 + 149 + if (!response.body) throw new Error('No body in SSE response'); 150 + 151 + const reader = response.body 152 + .pipeThrough(new TextDecoderStream()) 153 + .getReader(); 154 + 155 + let buffer = ''; 156 + 157 + const abortHandler = () => { 158 + try { 159 + reader.cancel(); 160 + } catch { 161 + // noop 162 + } 163 + }; 164 + 165 + signal.addEventListener('abort', abortHandler); 166 + 167 + try { 168 + while (true) { 169 + const { done, value } = await reader.read(); 170 + if (done) break; 171 + buffer += value; 172 + 173 + const chunks = buffer.split('\n\n'); 174 + buffer = chunks.pop() ?? ''; 175 + 176 + for (const chunk of chunks) { 177 + const lines = chunk.split('\n'); 178 + const dataLines: Array<string> = []; 179 + let eventName: string | undefined; 180 + 181 + for (const line of lines) { 182 + if (line.startsWith('data:')) { 183 + dataLines.push(line.replace(/^data:\s*/, '')); 184 + } else if (line.startsWith('event:')) { 185 + eventName = line.replace(/^event:\s*/, ''); 186 + } else if (line.startsWith('id:')) { 187 + lastEventId = line.replace(/^id:\s*/, ''); 188 + } else if (line.startsWith('retry:')) { 189 + const parsed = Number.parseInt( 190 + line.replace(/^retry:\s*/, ''), 191 + 10, 192 + ); 193 + if (!Number.isNaN(parsed)) { 194 + retryDelay = parsed; 195 + } 196 + } 197 + } 198 + 199 + let data: unknown; 200 + let parsedJson = false; 201 + 202 + if (dataLines.length) { 203 + const rawData = dataLines.join('\n'); 204 + try { 205 + data = JSON.parse(rawData); 206 + parsedJson = true; 207 + } catch { 208 + data = rawData; 209 + } 210 + } 211 + 212 + if (parsedJson) { 213 + if (responseValidator) { 214 + await responseValidator(data); 215 + } 216 + 217 + if (responseTransformer) { 218 + data = await responseTransformer(data); 219 + } 220 + } 221 + 222 + onSseEvent?.({ 223 + data, 224 + event: eventName, 225 + id: lastEventId, 226 + retry: retryDelay, 227 + }); 228 + 229 + if (dataLines.length) { 230 + yield data as any; 231 + } 232 + } 233 + } 234 + } finally { 235 + signal.removeEventListener('abort', abortHandler); 236 + reader.releaseLock(); 237 + } 238 + 239 + break; // exit loop on normal completion 240 + } catch (error) { 241 + // connection failed or aborted; retry after delay 242 + onSseError?.(error); 243 + 244 + if ( 245 + sseMaxRetryAttempts !== undefined && 246 + attempt >= sseMaxRetryAttempts 247 + ) { 248 + break; // stop after firing error 249 + } 250 + 251 + // exponential backoff: double retry each attempt, cap at 30s 252 + const backoff = Math.min( 253 + retryDelay * 2 ** (attempt - 1), 254 + sseMaxRetryDelay ?? 30000, 255 + ); 256 + await sleep(backoff); 257 + } 258 + } 259 + }; 260 + 261 + const stream = createStream(); 262 + 263 + return { stream }; 264 + };
+118
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { 5 + BodySerializer, 6 + QuerySerializer, 7 + QuerySerializerOptions, 8 + } from './bodySerializer.gen'; 9 + 10 + export type HttpMethod = 11 + | 'connect' 12 + | 'delete' 13 + | 'get' 14 + | 'head' 15 + | 'options' 16 + | 'patch' 17 + | 'post' 18 + | 'put' 19 + | 'trace'; 20 + 21 + export type Client< 22 + RequestFn = never, 23 + Config = unknown, 24 + MethodFn = never, 25 + BuildUrlFn = never, 26 + SseFn = never, 27 + > = { 28 + /** 29 + * Returns the final request URL. 30 + */ 31 + buildUrl: BuildUrlFn; 32 + getConfig: () => Config; 33 + request: RequestFn; 34 + setConfig: (config: Config) => Config; 35 + } & { 36 + [K in HttpMethod]: MethodFn; 37 + } & ([SseFn] extends [never] 38 + ? { sse?: never } 39 + : { sse: { [K in HttpMethod]: SseFn } }); 40 + 41 + export interface Config { 42 + /** 43 + * Auth token or a function returning auth token. The resolved value will be 44 + * added to the request payload as defined by its `security` array. 45 + */ 46 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 47 + /** 48 + * A function for serializing request body parameter. By default, 49 + * {@link JSON.stringify()} will be used. 50 + */ 51 + bodySerializer?: BodySerializer | null; 52 + /** 53 + * An object containing any HTTP headers that you want to pre-populate your 54 + * `Headers` object with. 55 + * 56 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 57 + */ 58 + headers?: 59 + | RequestInit['headers'] 60 + | Record< 61 + string, 62 + | string 63 + | number 64 + | boolean 65 + | (string | number | boolean)[] 66 + | null 67 + | undefined 68 + | unknown 69 + >; 70 + /** 71 + * The request method. 72 + * 73 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 74 + */ 75 + method?: Uppercase<HttpMethod>; 76 + /** 77 + * A function for serializing request query parameters. By default, arrays 78 + * will be exploded in form style, objects will be exploded in deepObject 79 + * style, and reserved characters are percent-encoded. 80 + * 81 + * This method will have no effect if the native `paramsSerializer()` Axios 82 + * API function is used. 83 + * 84 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 85 + */ 86 + querySerializer?: QuerySerializer | QuerySerializerOptions; 87 + /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 94 + * A function transforming response data before it's returned. This is useful 95 + * for post-processing data, e.g. converting ISO strings into Date objects. 96 + */ 97 + responseTransformer?: (data: unknown) => Promise<unknown>; 98 + /** 99 + * A function validating response data. This is useful if you want to ensure 100 + * the response conforms to the desired shape, so it can be safely passed to 101 + * the transformers and returned to the user. 102 + */ 103 + responseValidator?: (data: unknown) => Promise<unknown>; 104 + } 105 + 106 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 107 + ? true 108 + : [T] extends [never | undefined] 109 + ? [undefined] extends [T] 110 + ? false 111 + : true 112 + : false; 113 + 114 + export type OmitNever<T extends Record<string, unknown>> = { 115 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true 116 + ? never 117 + : K]: T[K]; 118 + };
+114
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace( 48 + match, 49 + serializeArrayParam({ explode, name, style, value }), 50 + ); 51 + continue; 52 + } 53 + 54 + if (typeof value === 'object') { 55 + url = url.replace( 56 + match, 57 + serializeObjectParam({ 58 + explode, 59 + name, 60 + style, 61 + value: value as Record<string, unknown>, 62 + valueOnly: true, 63 + }), 64 + ); 65 + continue; 66 + } 67 + 68 + if (style === 'matrix') { 69 + url = url.replace( 70 + match, 71 + `;${serializePrimitiveParam({ 72 + name, 73 + value: value as string, 74 + })}`, 75 + ); 76 + continue; 77 + } 78 + 79 + const replaceValue = encodeURIComponent( 80 + style === 'label' ? `.${value as string}` : (value as string), 81 + ); 82 + url = url.replace(match, replaceValue); 83 + } 84 + } 85 + return url; 86 + }; 87 + 88 + export const getUrl = ({ 89 + baseUrl, 90 + path, 91 + query, 92 + querySerializer, 93 + url: _url, 94 + }: { 95 + baseUrl?: string; 96 + path?: Record<string, unknown>; 97 + query?: Record<string, unknown>; 98 + querySerializer: QuerySerializer; 99 + url: string; 100 + }) => { 101 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 102 + let url = (baseUrl ?? '') + pathUrl; 103 + if (path) { 104 + url = defaultPathSerializer({ path, url }); 105 + } 106 + let search = query ? querySerializer(query) : ''; 107 + if (search.startsWith('?')) { 108 + search = search.substring(1); 109 + } 110 + if (search) { 111 + url += `?${search}`; 112 + } 113 + return url; 114 + };
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './sdk.gen';
+423
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; 4 + 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'; 5 + import { client as _heyApiClient } from './client.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => { 22 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 23 + url: '/api/v{api-version}/no+tag', 24 + ...options 25 + }); 26 + }; 27 + 28 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => { 29 + return (options?.client ?? _heyApiClient).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ 30 + url: '/api/v{api-version}/no+tag', 31 + ...options 32 + }); 33 + }; 34 + 35 + export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => { 36 + return (options.client ?? _heyApiClient).post<ImportResponses, unknown, ThrowOnError>({ 37 + responseType: 'json', 38 + url: '/api/v{api-version}/no+tag', 39 + ...options, 40 + headers: { 41 + 'Content-Type': 'application/json', 42 + ...options.headers 43 + } 44 + }); 45 + }; 46 + 47 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => { 48 + return (options?.client ?? _heyApiClient).put<FooWowResponses, unknown, ThrowOnError>({ 49 + url: '/api/v{api-version}/no+tag', 50 + ...options 51 + }); 52 + }; 53 + 54 + export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => { 55 + return (options?.client ?? _heyApiClient).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ 56 + responseType: 'json', 57 + url: '/api/v{api-version}/simple/$count', 58 + ...options 59 + }); 60 + }; 61 + 62 + export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => { 63 + return (options.client ?? _heyApiClient).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ 64 + responseType: 'json', 65 + url: '/api/v{api-version}/simple:operation', 66 + ...options 67 + }); 68 + }; 69 + 70 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => { 71 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 72 + url: '/api/v{api-version}/simple', 73 + ...options 74 + }); 75 + }; 76 + 77 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => { 78 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 79 + url: '/api/v{api-version}/simple', 80 + ...options 81 + }); 82 + }; 83 + 84 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => { 85 + return (options?.client ?? _heyApiClient).head<unknown, unknown, ThrowOnError>({ 86 + url: '/api/v{api-version}/simple', 87 + ...options 88 + }); 89 + }; 90 + 91 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => { 92 + return (options?.client ?? _heyApiClient).options<unknown, unknown, ThrowOnError>({ 93 + url: '/api/v{api-version}/simple', 94 + ...options 95 + }); 96 + }; 97 + 98 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => { 99 + return (options?.client ?? _heyApiClient).patch<unknown, unknown, ThrowOnError>({ 100 + url: '/api/v{api-version}/simple', 101 + ...options 102 + }); 103 + }; 104 + 105 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => { 106 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 107 + url: '/api/v{api-version}/simple', 108 + ...options 109 + }); 110 + }; 111 + 112 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => { 113 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 114 + url: '/api/v{api-version}/simple', 115 + ...options 116 + }); 117 + }; 118 + 119 + export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => { 120 + return (options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 121 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 122 + ...options 123 + }); 124 + }; 125 + 126 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 127 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 128 + url: '/api/v{api-version}/descriptions', 129 + ...options 130 + }); 131 + }; 132 + 133 + /** 134 + * @deprecated 135 + */ 136 + export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => { 137 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 138 + url: '/api/v{api-version}/parameters/deprecated', 139 + ...options 140 + }); 141 + }; 142 + 143 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => { 144 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 145 + url: '/api/v{api-version}/parameters/{parameterPath}', 146 + ...options, 147 + headers: { 148 + 'Content-Type': 'application/json', 149 + ...options.headers 150 + } 151 + }); 152 + }; 153 + 154 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 155 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 156 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 157 + ...options, 158 + headers: { 159 + 'Content-Type': 'application/json', 160 + ...options.headers 161 + } 162 + }); 163 + }; 164 + 165 + export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => { 166 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 167 + url: '/api/v{api-version}/parameters', 168 + ...options, 169 + headers: { 170 + 'Content-Type': 'application/json', 171 + ...options.headers 172 + } 173 + }); 174 + }; 175 + 176 + export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => { 177 + return (options.client ?? _heyApiClient).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 178 + responseType: 'json', 179 + url: '/api/v{api-version}/parameters', 180 + ...options, 181 + headers: { 182 + 'Content-Type': 'application/json', 183 + ...options.headers 184 + } 185 + }); 186 + }; 187 + 188 + export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => { 189 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 190 + url: '/api/v{api-version}/requestBody', 191 + ...options, 192 + headers: { 193 + 'Content-Type': 'application/json', 194 + ...options?.headers 195 + } 196 + }); 197 + }; 198 + 199 + export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => { 200 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 201 + ...formDataBodySerializer, 202 + url: '/api/v{api-version}/formData', 203 + ...options, 204 + headers: { 205 + 'Content-Type': null, 206 + ...options?.headers 207 + } 208 + }); 209 + }; 210 + 211 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => { 212 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 213 + url: '/api/v{api-version}/defaults', 214 + ...options 215 + }); 216 + }; 217 + 218 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => { 219 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 220 + url: '/api/v{api-version}/defaults', 221 + ...options 222 + }); 223 + }; 224 + 225 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => { 226 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 227 + url: '/api/v{api-version}/defaults', 228 + ...options 229 + }); 230 + }; 231 + 232 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => { 233 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 234 + url: '/api/v{api-version}/duplicate', 235 + ...options 236 + }); 237 + }; 238 + 239 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => { 240 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 241 + url: '/api/v{api-version}/duplicate', 242 + ...options 243 + }); 244 + }; 245 + 246 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => { 247 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 248 + url: '/api/v{api-version}/duplicate', 249 + ...options 250 + }); 251 + }; 252 + 253 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => { 254 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 255 + url: '/api/v{api-version}/duplicate', 256 + ...options 257 + }); 258 + }; 259 + 260 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => { 261 + return (options?.client ?? _heyApiClient).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ 262 + url: '/api/v{api-version}/no-content', 263 + ...options 264 + }); 265 + }; 266 + 267 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => { 268 + return (options?.client ?? _heyApiClient).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ 269 + responseType: 'json', 270 + url: '/api/v{api-version}/multiple-tags/response-and-no-content', 271 + ...options 272 + }); 273 + }; 274 + 275 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => { 276 + return (options?.client ?? _heyApiClient).get<DummyAResponses, unknown, ThrowOnError>({ 277 + responseType: 'json', 278 + url: '/api/v{api-version}/multiple-tags/a', 279 + ...options 280 + }); 281 + }; 282 + 283 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => { 284 + return (options?.client ?? _heyApiClient).get<DummyBResponses, unknown, ThrowOnError>({ 285 + url: '/api/v{api-version}/multiple-tags/b', 286 + ...options 287 + }); 288 + }; 289 + 290 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => { 291 + return (options?.client ?? _heyApiClient).get<CallWithResponseResponses, unknown, ThrowOnError>({ 292 + url: '/api/v{api-version}/response', 293 + ...options 294 + }); 295 + }; 296 + 297 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => { 298 + return (options?.client ?? _heyApiClient).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ 299 + responseType: 'json', 300 + url: '/api/v{api-version}/response', 301 + ...options 302 + }); 303 + }; 304 + 305 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => { 306 + return (options?.client ?? _heyApiClient).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ 307 + responseType: 'json', 308 + url: '/api/v{api-version}/response', 309 + ...options 310 + }); 311 + }; 312 + 313 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => { 314 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 315 + url: '/api/v{api-version}/collectionFormat', 316 + ...options 317 + }); 318 + }; 319 + 320 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 321 + return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 322 + responseType: 'json', 323 + url: '/api/v{api-version}/types', 324 + ...options 325 + }); 326 + }; 327 + 328 + export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => { 329 + return (options.client ?? _heyApiClient).post<UploadFileResponses, unknown, ThrowOnError>({ 330 + ...urlSearchParamsBodySerializer, 331 + responseType: 'json', 332 + url: '/api/v{api-version}/upload', 333 + ...options, 334 + headers: { 335 + 'Content-Type': 'application/x-www-form-urlencoded', 336 + ...options.headers 337 + } 338 + }); 339 + }; 340 + 341 + export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => { 342 + return (options.client ?? _heyApiClient).get<FileResponseResponses, unknown, ThrowOnError>({ 343 + responseType: 'blob', 344 + url: '/api/v{api-version}/file/{id}', 345 + ...options 346 + }); 347 + }; 348 + 349 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => { 350 + return (options.client ?? _heyApiClient).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 351 + responseType: 'json', 352 + url: '/api/v{api-version}/complex', 353 + ...options 354 + }); 355 + }; 356 + 357 + export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => { 358 + return (options?.client ?? _heyApiClient).get<MultipartResponseResponses, unknown, ThrowOnError>({ 359 + url: '/api/v{api-version}/multipart', 360 + ...options 361 + }); 362 + }; 363 + 364 + export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => { 365 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 366 + ...formDataBodySerializer, 367 + url: '/api/v{api-version}/multipart', 368 + ...options, 369 + headers: { 370 + 'Content-Type': null, 371 + ...options?.headers 372 + } 373 + }); 374 + }; 375 + 376 + export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => { 377 + return (options.client ?? _heyApiClient).put<ComplexParamsResponses, unknown, ThrowOnError>({ 378 + responseType: 'json', 379 + url: '/api/v{api-version}/complex/{id}', 380 + ...options, 381 + headers: { 382 + 'Content-Type': 'application/json-patch+json', 383 + ...options.headers 384 + } 385 + }); 386 + }; 387 + 388 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => { 389 + return (options?.client ?? _heyApiClient).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ 390 + url: '/api/v{api-version}/header', 391 + ...options 392 + }); 393 + }; 394 + 395 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => { 396 + return (options.client ?? _heyApiClient).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ 397 + url: '/api/v{api-version}/error', 398 + ...options 399 + }); 400 + }; 401 + 402 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => { 403 + return (options.client ?? _heyApiClient).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ 404 + responseType: 'json', 405 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 406 + ...options 407 + }); 408 + }; 409 + 410 + /** 411 + * Login User 412 + */ 413 + export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => { 414 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 415 + ...urlSearchParamsBodySerializer, 416 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 417 + ...options, 418 + headers: { 419 + 'Content-Type': 'application/x-www-form-urlencoded', 420 + ...options.headers 421 + } 422 + }); 423 + };
+2063
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * External ref to shared model (A) 10 + */ 11 + export type ExternalRefA = { 12 + id: string; 13 + name?: string; 14 + }; 15 + 16 + /** 17 + * External ref to shared model (B) 18 + */ 19 + export type ExternalRefB = ExternalRefA; 20 + 21 + /** 22 + * Testing multiline comments in string: First line 23 + * Second line 24 + * 25 + * Fourth line 26 + */ 27 + export type CamelCaseCommentWithBreaks = number; 28 + 29 + /** 30 + * Testing multiline comments in string: First line 31 + * Second line 32 + * 33 + * Fourth line 34 + */ 35 + export type CommentWithBreaks = number; 36 + 37 + /** 38 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 39 + */ 40 + export type CommentWithBackticks = number; 41 + 42 + /** 43 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 44 + */ 45 + export type CommentWithBackticksAndQuotes = number; 46 + 47 + /** 48 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 49 + */ 50 + export type CommentWithSlashes = number; 51 + 52 + /** 53 + * Testing expression placeholders in string: ${expression} should work 54 + */ 55 + export type CommentWithExpressionPlaceholders = number; 56 + 57 + /** 58 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 59 + */ 60 + export type CommentWithQuotes = number; 61 + 62 + /** 63 + * Testing reserved characters in string: * inline * and ** inline ** should work 64 + */ 65 + export type CommentWithReservedCharacters = number; 66 + 67 + /** 68 + * This is a simple number 69 + */ 70 + export type SimpleInteger = number; 71 + 72 + /** 73 + * This is a simple boolean 74 + */ 75 + export type SimpleBoolean = boolean; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export type SimpleString = string; 81 + 82 + /** 83 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 84 + */ 85 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 86 + 87 + /** 88 + * This is a simple file 89 + */ 90 + export type SimpleFile = Blob | File; 91 + 92 + /** 93 + * This is a simple reference 94 + */ 95 + export type SimpleReference = ModelWithString; 96 + 97 + /** 98 + * This is a simple string 99 + */ 100 + export type SimpleStringWithPattern = string | null; 101 + 102 + /** 103 + * This is a simple enum with strings 104 + */ 105 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 106 + 107 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 108 + 109 + /** 110 + * This is a simple enum with numbers 111 + */ 112 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 113 + 114 + /** 115 + * Success=1,Warning=2,Error=3 116 + */ 117 + export type EnumFromDescription = number; 118 + 119 + /** 120 + * This is a simple enum with numbers 121 + */ 122 + export type EnumWithExtensions = 200 | 400 | 500; 123 + 124 + export type EnumWithXEnumNames = 0 | 1 | 2; 125 + 126 + /** 127 + * This is a simple array with numbers 128 + */ 129 + export type ArrayWithNumbers = Array<number>; 130 + 131 + /** 132 + * This is a simple array with booleans 133 + */ 134 + export type ArrayWithBooleans = Array<boolean>; 135 + 136 + /** 137 + * This is a simple array with strings 138 + */ 139 + export type ArrayWithStrings = Array<string>; 140 + 141 + /** 142 + * This is a simple array with references 143 + */ 144 + export type ArrayWithReferences = Array<ModelWithString>; 145 + 146 + /** 147 + * This is a simple array containing an array 148 + */ 149 + export type ArrayWithArray = Array<Array<ModelWithString>>; 150 + 151 + /** 152 + * This is a simple array with properties 153 + */ 154 + export type ArrayWithProperties = Array<{ 155 + '16x16'?: CamelCaseCommentWithBreaks; 156 + bar?: string; 157 + }>; 158 + 159 + /** 160 + * This is a simple array with any of properties 161 + */ 162 + export type ArrayWithAnyOfProperties = Array<{ 163 + foo?: string; 164 + } | { 165 + bar?: string; 166 + }>; 167 + 168 + export type AnyOfAnyAndNull = { 169 + data?: unknown | null; 170 + }; 171 + 172 + /** 173 + * This is a simple array with any of properties 174 + */ 175 + export type AnyOfArrays = { 176 + results?: Array<{ 177 + foo?: string; 178 + } | { 179 + bar?: string; 180 + }>; 181 + }; 182 + 183 + /** 184 + * This is a string dictionary 185 + */ 186 + export type DictionaryWithString = { 187 + [key: string]: string; 188 + }; 189 + 190 + export type DictionaryWithPropertiesAndAdditionalProperties = { 191 + foo?: number; 192 + bar?: boolean; 193 + [key: string]: string | number | boolean | undefined; 194 + }; 195 + 196 + /** 197 + * This is a string reference 198 + */ 199 + export type DictionaryWithReference = { 200 + [key: string]: ModelWithString; 201 + }; 202 + 203 + /** 204 + * This is a complex dictionary 205 + */ 206 + export type DictionaryWithArray = { 207 + [key: string]: Array<ModelWithString>; 208 + }; 209 + 210 + /** 211 + * This is a string dictionary 212 + */ 213 + export type DictionaryWithDictionary = { 214 + [key: string]: { 215 + [key: string]: string; 216 + }; 217 + }; 218 + 219 + /** 220 + * This is a complex dictionary 221 + */ 222 + export type DictionaryWithProperties = { 223 + [key: string]: { 224 + foo?: string; 225 + bar?: string; 226 + }; 227 + }; 228 + 229 + /** 230 + * This is a model with one number property 231 + */ 232 + export type ModelWithInteger = { 233 + /** 234 + * This is a simple number property 235 + */ 236 + prop?: number; 237 + }; 238 + 239 + /** 240 + * This is a model with one boolean property 241 + */ 242 + export type ModelWithBoolean = { 243 + /** 244 + * This is a simple boolean property 245 + */ 246 + prop?: boolean; 247 + }; 248 + 249 + /** 250 + * This is a model with one string property 251 + */ 252 + export type ModelWithString = { 253 + /** 254 + * This is a simple string property 255 + */ 256 + prop?: string; 257 + }; 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export type ModelWithStringError = { 263 + /** 264 + * This is a simple string property 265 + */ 266 + prop?: string; 267 + }; 268 + 269 + /** 270 + * `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) 271 + */ 272 + export type ModelFromZendesk = string; 273 + 274 + /** 275 + * This is a model with one string property 276 + */ 277 + export type ModelWithNullableString = { 278 + /** 279 + * This is a simple string property 280 + */ 281 + nullableProp1?: string | null; 282 + /** 283 + * This is a simple string property 284 + */ 285 + nullableRequiredProp1: string | null; 286 + /** 287 + * This is a simple string property 288 + */ 289 + nullableProp2?: string | null; 290 + /** 291 + * This is a simple string property 292 + */ 293 + nullableRequiredProp2: string | null; 294 + /** 295 + * This is a simple enum with strings 296 + */ 297 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 298 + }; 299 + 300 + /** 301 + * This is a model with one enum 302 + */ 303 + export type ModelWithEnum = { 304 + /** 305 + * This is a simple enum with strings 306 + */ 307 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 308 + /** 309 + * These are the HTTP error code enums 310 + */ 311 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 312 + /** 313 + * Simple boolean enum 314 + */ 315 + bool?: true; 316 + }; 317 + 318 + /** 319 + * This is a model with one enum with escaped name 320 + */ 321 + export type ModelWithEnumWithHyphen = { 322 + /** 323 + * Foo-Bar-Baz-Qux 324 + */ 325 + 'foo-bar-baz-qux'?: '3.0'; 326 + }; 327 + 328 + /** 329 + * This is a model with one enum 330 + */ 331 + export type ModelWithEnumFromDescription = { 332 + /** 333 + * Success=1,Warning=2,Error=3 334 + */ 335 + test?: number; 336 + }; 337 + 338 + /** 339 + * This is a model with nested enums 340 + */ 341 + export type ModelWithNestedEnums = { 342 + dictionaryWithEnum?: { 343 + [key: string]: 'Success' | 'Warning' | 'Error'; 344 + }; 345 + dictionaryWithEnumFromDescription?: { 346 + [key: string]: number; 347 + }; 348 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 349 + arrayWithDescription?: Array<number>; 350 + /** 351 + * This is a simple enum with strings 352 + */ 353 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 354 + }; 355 + 356 + /** 357 + * This is a model with one property containing a reference 358 + */ 359 + export type ModelWithReference = { 360 + prop?: ModelWithProperties; 361 + }; 362 + 363 + /** 364 + * This is a model with one property containing an array 365 + */ 366 + export type ModelWithArrayReadOnlyAndWriteOnly = { 367 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 368 + propWithFile?: Array<Blob | File>; 369 + propWithNumber?: Array<number>; 370 + }; 371 + 372 + /** 373 + * This is a model with one property containing an array 374 + */ 375 + export type ModelWithArray = { 376 + prop?: Array<ModelWithString>; 377 + propWithFile?: Array<Blob | File>; 378 + propWithNumber?: Array<number>; 379 + }; 380 + 381 + /** 382 + * This is a model with one property containing a dictionary 383 + */ 384 + export type ModelWithDictionary = { 385 + prop?: { 386 + [key: string]: string; 387 + }; 388 + }; 389 + 390 + /** 391 + * This is a deprecated model with a deprecated property 392 + * @deprecated 393 + */ 394 + export type DeprecatedModel = { 395 + /** 396 + * This is a deprecated property 397 + * @deprecated 398 + */ 399 + prop?: string; 400 + }; 401 + 402 + /** 403 + * This is a model with one property containing a circular reference 404 + */ 405 + export type ModelWithCircularReference = { 406 + prop?: ModelWithCircularReference; 407 + }; 408 + 409 + /** 410 + * This is a model with one property with a 'one of' relationship 411 + */ 412 + export type CompositionWithOneOf = { 413 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 414 + }; 415 + 416 + /** 417 + * This is a model with one property with a 'one of' relationship where the options are not $ref 418 + */ 419 + export type CompositionWithOneOfAnonymous = { 420 + propA?: { 421 + propA?: string; 422 + } | string | number; 423 + }; 424 + 425 + /** 426 + * Circle 427 + */ 428 + export type ModelCircle = { 429 + kind: string; 430 + radius?: number; 431 + }; 432 + 433 + /** 434 + * Square 435 + */ 436 + export type ModelSquare = { 437 + kind: string; 438 + sideLength?: number; 439 + }; 440 + 441 + /** 442 + * This is a model with one property with a 'one of' relationship where the options are not $ref 443 + */ 444 + export type CompositionWithOneOfDiscriminator = ({ 445 + kind: 'circle'; 446 + } & ModelCircle) | ({ 447 + kind: 'square'; 448 + } & ModelSquare); 449 + 450 + /** 451 + * This is a model with one property with a 'any of' relationship 452 + */ 453 + export type CompositionWithAnyOf = { 454 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 455 + }; 456 + 457 + /** 458 + * This is a model with one property with a 'any of' relationship where the options are not $ref 459 + */ 460 + export type CompositionWithAnyOfAnonymous = { 461 + propA?: { 462 + propA?: string; 463 + } | string | number; 464 + }; 465 + 466 + /** 467 + * This is a model with nested 'any of' property with a type null 468 + */ 469 + export type CompositionWithNestedAnyAndTypeNull = { 470 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 471 + }; 472 + 473 + export type _3eNum1Период = 'Bird' | 'Dog'; 474 + 475 + export type ConstValue = 'ConstValue'; 476 + 477 + /** 478 + * This is a model with one property with a 'any of' relationship where the options are not $ref 479 + */ 480 + export type CompositionWithNestedAnyOfAndNull = { 481 + /** 482 + * Scopes 483 + */ 484 + propA?: Array<_3eNum1Период | ConstValue> | null; 485 + }; 486 + 487 + /** 488 + * This is a model with one property with a 'one of' relationship 489 + */ 490 + export type CompositionWithOneOfAndNullable = { 491 + propA?: { 492 + boolean?: boolean; 493 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 494 + }; 495 + 496 + /** 497 + * This is a model that contains a simple dictionary within composition 498 + */ 499 + export type CompositionWithOneOfAndSimpleDictionary = { 500 + propA?: boolean | { 501 + [key: string]: number; 502 + }; 503 + }; 504 + 505 + /** 506 + * This is a model that contains a dictionary of simple arrays within composition 507 + */ 508 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 509 + propA?: boolean | { 510 + [key: string]: Array<boolean>; 511 + }; 512 + }; 513 + 514 + /** 515 + * This is a model that contains a dictionary of complex arrays (composited) within composition 516 + */ 517 + export type CompositionWithOneOfAndComplexArrayDictionary = { 518 + propA?: boolean | { 519 + [key: string]: Array<number | string>; 520 + }; 521 + }; 522 + 523 + /** 524 + * This is a model with one property with a 'all of' relationship 525 + */ 526 + export type CompositionWithAllOfAndNullable = { 527 + propA?: ({ 528 + boolean?: boolean; 529 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 530 + }; 531 + 532 + /** 533 + * This is a model with one property with a 'any of' relationship 534 + */ 535 + export type CompositionWithAnyOfAndNullable = { 536 + propA?: { 537 + boolean?: boolean; 538 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 539 + }; 540 + 541 + /** 542 + * This is a base model with two simple optional properties 543 + */ 544 + export type CompositionBaseModel = { 545 + firstName?: string; 546 + lastname?: string; 547 + }; 548 + 549 + /** 550 + * This is a model that extends the base model 551 + */ 552 + export type CompositionExtendedModel = CompositionBaseModel & { 553 + age: number; 554 + firstName: string; 555 + lastname: string; 556 + }; 557 + 558 + /** 559 + * This is a model with one nested property 560 + */ 561 + export type ModelWithProperties = { 562 + required: string; 563 + readonly requiredAndReadOnly: string; 564 + requiredAndNullable: string | null; 565 + string?: string; 566 + number?: number; 567 + boolean?: boolean; 568 + reference?: ModelWithString; 569 + 'property with space'?: string; 570 + default?: string; 571 + try?: string; 572 + readonly '@namespace.string'?: string; 573 + readonly '@namespace.integer'?: number; 574 + }; 575 + 576 + /** 577 + * This is a model with one nested property 578 + */ 579 + export type ModelWithNestedProperties = { 580 + readonly first: { 581 + readonly second: { 582 + readonly third: string | null; 583 + } | null; 584 + } | null; 585 + }; 586 + 587 + /** 588 + * This is a model with duplicated properties 589 + */ 590 + export type ModelWithDuplicateProperties = { 591 + prop?: ModelWithString; 592 + }; 593 + 594 + /** 595 + * This is a model with ordered properties 596 + */ 597 + export type ModelWithOrderedProperties = { 598 + zebra?: string; 599 + apple?: string; 600 + hawaii?: string; 601 + }; 602 + 603 + /** 604 + * This is a model with duplicated imports 605 + */ 606 + export type ModelWithDuplicateImports = { 607 + propA?: ModelWithString; 608 + propB?: ModelWithString; 609 + propC?: ModelWithString; 610 + }; 611 + 612 + /** 613 + * This is a model that extends another model 614 + */ 615 + export type ModelThatExtends = ModelWithString & { 616 + propExtendsA?: string; 617 + propExtendsB?: ModelWithString; 618 + }; 619 + 620 + /** 621 + * This is a model that extends another model 622 + */ 623 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 624 + propExtendsC?: string; 625 + propExtendsD?: ModelWithString; 626 + }; 627 + 628 + /** 629 + * This is a model that contains a some patterns 630 + */ 631 + export type ModelWithPattern = { 632 + key: string; 633 + name: string; 634 + readonly enabled?: boolean; 635 + readonly modified?: string; 636 + id?: string; 637 + text?: string; 638 + patternWithSingleQuotes?: string; 639 + patternWithNewline?: string; 640 + patternWithBacktick?: string; 641 + }; 642 + 643 + export type File = { 644 + /** 645 + * Id 646 + */ 647 + readonly id?: string; 648 + /** 649 + * Updated at 650 + */ 651 + readonly updated_at?: string; 652 + /** 653 + * Created at 654 + */ 655 + readonly created_at?: string; 656 + /** 657 + * Mime 658 + */ 659 + mime: string; 660 + /** 661 + * File 662 + */ 663 + readonly file?: string; 664 + }; 665 + 666 + export type Default = { 667 + name?: string; 668 + }; 669 + 670 + export type Pageable = { 671 + page?: number; 672 + size?: number; 673 + sort?: Array<string>; 674 + }; 675 + 676 + /** 677 + * This is a free-form object without additionalProperties. 678 + */ 679 + export type FreeFormObjectWithoutAdditionalProperties = { 680 + [key: string]: unknown; 681 + }; 682 + 683 + /** 684 + * This is a free-form object with additionalProperties: true. 685 + */ 686 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 687 + [key: string]: unknown; 688 + }; 689 + 690 + /** 691 + * This is a free-form object with additionalProperties: {}. 692 + */ 693 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 694 + [key: string]: unknown; 695 + }; 696 + 697 + export type ModelWithConst = { 698 + String?: 'String'; 699 + number?: 0; 700 + null?: null; 701 + withType?: 'Some string'; 702 + }; 703 + 704 + /** 705 + * This is a model with one property and additionalProperties: true 706 + */ 707 + export type ModelWithAdditionalPropertiesEqTrue = { 708 + /** 709 + * This is a simple string property 710 + */ 711 + prop?: string; 712 + [key: string]: unknown | string | undefined; 713 + }; 714 + 715 + export type NestedAnyOfArraysNullable = { 716 + nullableArray?: Array<string | boolean> | null; 717 + }; 718 + 719 + export type CompositionWithOneOfAndProperties = ({ 720 + foo: SimpleParameter; 721 + } | { 722 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 723 + }) & { 724 + baz: number | null; 725 + qux: number; 726 + }; 727 + 728 + /** 729 + * An object that can be null 730 + */ 731 + export type NullableObject = { 732 + foo?: string; 733 + } | null; 734 + 735 + /** 736 + * Some % character 737 + */ 738 + export type CharactersInDescription = string; 739 + 740 + export type ModelWithNullableObject = { 741 + data?: NullableObject; 742 + }; 743 + 744 + export type ModelWithOneOfEnum = { 745 + foo: 'Bar'; 746 + } | { 747 + foo: 'Baz'; 748 + } | { 749 + foo: 'Qux'; 750 + } | { 751 + content: string; 752 + foo: 'Quux'; 753 + } | { 754 + content: [ 755 + string, 756 + string 757 + ]; 758 + foo: 'Corge'; 759 + }; 760 + 761 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 762 + 763 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 764 + 765 + export type ModelWithNestedArrayEnumsData = { 766 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 767 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 768 + }; 769 + 770 + export type ModelWithNestedArrayEnums = { 771 + array_strings?: Array<string>; 772 + data?: ModelWithNestedArrayEnumsData; 773 + }; 774 + 775 + export type ModelWithNestedCompositionEnums = { 776 + foo?: ModelWithNestedArrayEnumsDataFoo; 777 + }; 778 + 779 + export type ModelWithReadOnlyAndWriteOnly = { 780 + foo: string; 781 + readonly bar: string; 782 + }; 783 + 784 + export type ModelWithConstantSizeArray = [ 785 + number, 786 + number 787 + ]; 788 + 789 + export type ModelWithAnyOfConstantSizeArray = [ 790 + number | string, 791 + number | string, 792 + number | string 793 + ]; 794 + 795 + export type ModelWithPrefixItemsConstantSizeArray = [ 796 + ModelWithInteger, 797 + number | string, 798 + string 799 + ]; 800 + 801 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 802 + number | null | string, 803 + number | null | string, 804 + number | null | string 805 + ]; 806 + 807 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 808 + number | Import, 809 + number | Import 810 + ]; 811 + 812 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 813 + number & string, 814 + number & string 815 + ]; 816 + 817 + export type ModelWithNumericEnumUnion = { 818 + /** 819 + * Период 820 + */ 821 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 822 + }; 823 + 824 + /** 825 + * Some description with `back ticks` 826 + */ 827 + export type ModelWithBackticksInDescription = { 828 + /** 829 + * The template `that` should be used for parsing and importing the contents of the CSV file. 830 + * 831 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 832 + * <pre> 833 + * [ 834 + * { 835 + * "resourceType": "Asset", 836 + * "identifier": { 837 + * "name": "${1}", 838 + * "domain": { 839 + * "name": "${2}", 840 + * "community": { 841 + * "name": "Some Community" 842 + * } 843 + * } 844 + * }, 845 + * "attributes" : { 846 + * "00000000-0000-0000-0000-000000003115" : [ { 847 + * "value" : "${3}" 848 + * } ], 849 + * "00000000-0000-0000-0000-000000000222" : [ { 850 + * "value" : "${4}" 851 + * } ] 852 + * } 853 + * } 854 + * ] 855 + * </pre> 856 + */ 857 + template?: string; 858 + }; 859 + 860 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 861 + baz: number | null; 862 + qux: number; 863 + }; 864 + 865 + /** 866 + * Model used to test deduplication strategy (unused) 867 + */ 868 + export type ParameterSimpleParameterUnused = string; 869 + 870 + /** 871 + * Model used to test deduplication strategy 872 + */ 873 + export type PostServiceWithEmptyTagResponse = string; 874 + 875 + /** 876 + * Model used to test deduplication strategy 877 + */ 878 + export type PostServiceWithEmptyTagResponse2 = string; 879 + 880 + /** 881 + * Model used to test deduplication strategy 882 + */ 883 + export type DeleteFooData = string; 884 + 885 + /** 886 + * Model used to test deduplication strategy 887 + */ 888 + export type DeleteFooData2 = string; 889 + 890 + /** 891 + * Model with restricted keyword name 892 + */ 893 + export type Import = string; 894 + 895 + export type SchemaWithFormRestrictedKeys = { 896 + description?: string; 897 + 'x-enum-descriptions'?: string; 898 + 'x-enum-varnames'?: string; 899 + 'x-enumNames'?: string; 900 + title?: string; 901 + object?: { 902 + description?: string; 903 + 'x-enum-descriptions'?: string; 904 + 'x-enum-varnames'?: string; 905 + 'x-enumNames'?: string; 906 + title?: string; 907 + }; 908 + array?: Array<{ 909 + description?: string; 910 + 'x-enum-descriptions'?: string; 911 + 'x-enum-varnames'?: string; 912 + 'x-enumNames'?: string; 913 + title?: string; 914 + }>; 915 + }; 916 + 917 + /** 918 + * This schema was giving PascalCase transformations a hard time 919 + */ 920 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 921 + /** 922 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 923 + */ 924 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 925 + }; 926 + 927 + /** 928 + * This schema was giving PascalCase transformations a hard time 929 + */ 930 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 931 + /** 932 + * Specifies the target ResourceVersion 933 + */ 934 + resourceVersion?: string; 935 + /** 936 + * Specifies the target UID. 937 + */ 938 + uid?: string; 939 + }; 940 + 941 + export type AdditionalPropertiesUnknownIssue = { 942 + [key: string]: string | number; 943 + }; 944 + 945 + export type AdditionalPropertiesUnknownIssue2 = { 946 + [key: string]: string | number; 947 + }; 948 + 949 + export type AdditionalPropertiesUnknownIssue3 = string & { 950 + entries: { 951 + [key: string]: AdditionalPropertiesUnknownIssue; 952 + }; 953 + }; 954 + 955 + export type AdditionalPropertiesIntegerIssue = { 956 + value: number; 957 + [key: string]: number; 958 + }; 959 + 960 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 961 + 962 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 963 + item?: boolean; 964 + error?: string | null; 965 + readonly hasError?: boolean; 966 + data?: { 967 + [key: string]: never; 968 + }; 969 + }; 970 + 971 + export type GenericSchemaDuplicateIssue1SystemString = { 972 + item?: string | null; 973 + error?: string | null; 974 + readonly hasError?: boolean; 975 + }; 976 + 977 + /** 978 + * This is a model with one nested property 979 + */ 980 + export type ModelWithPropertiesWritable = { 981 + required: string; 982 + requiredAndNullable: string | null; 983 + string?: string; 984 + number?: number; 985 + boolean?: boolean; 986 + reference?: ModelWithString; 987 + 'property with space'?: string; 988 + default?: string; 989 + try?: string; 990 + }; 991 + 992 + /** 993 + * This is a model that contains a some patterns 994 + */ 995 + export type ModelWithPatternWritable = { 996 + key: string; 997 + name: string; 998 + id?: string; 999 + text?: string; 1000 + patternWithSingleQuotes?: string; 1001 + patternWithNewline?: string; 1002 + patternWithBacktick?: string; 1003 + }; 1004 + 1005 + export type FileWritable = { 1006 + /** 1007 + * Mime 1008 + */ 1009 + mime: string; 1010 + }; 1011 + 1012 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1013 + foo: string; 1014 + baz: string; 1015 + }; 1016 + 1017 + export type AdditionalPropertiesUnknownIssueWritable = { 1018 + [key: string]: string | number; 1019 + }; 1020 + 1021 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1022 + item?: boolean; 1023 + error?: string | null; 1024 + data?: { 1025 + [key: string]: never; 1026 + }; 1027 + }; 1028 + 1029 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1030 + item?: string | null; 1031 + error?: string | null; 1032 + }; 1033 + 1034 + /** 1035 + * This is a reusable parameter 1036 + */ 1037 + export type SimpleParameter = string; 1038 + 1039 + /** 1040 + * Parameter with illegal characters 1041 + */ 1042 + export type XFooBar = ModelWithString; 1043 + 1044 + /** 1045 + * A reusable request body 1046 + */ 1047 + export type SimpleRequestBody = ModelWithString; 1048 + 1049 + /** 1050 + * A reusable request body 1051 + */ 1052 + export type SimpleFormData = ModelWithString; 1053 + 1054 + export type ExportData = { 1055 + body?: never; 1056 + path?: never; 1057 + query?: never; 1058 + url: '/api/v{api-version}/no+tag'; 1059 + }; 1060 + 1061 + export type PatchApiVbyApiVersionNoTagData = { 1062 + body?: never; 1063 + path?: never; 1064 + query?: never; 1065 + url: '/api/v{api-version}/no+tag'; 1066 + }; 1067 + 1068 + export type PatchApiVbyApiVersionNoTagResponses = { 1069 + /** 1070 + * OK 1071 + */ 1072 + default: unknown; 1073 + }; 1074 + 1075 + export type ImportData = { 1076 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; 1077 + path?: never; 1078 + query?: never; 1079 + url: '/api/v{api-version}/no+tag'; 1080 + }; 1081 + 1082 + export type ImportResponses = { 1083 + /** 1084 + * Success 1085 + */ 1086 + 200: ModelFromZendesk; 1087 + /** 1088 + * Default success response 1089 + */ 1090 + default: ModelWithReadOnlyAndWriteOnly; 1091 + }; 1092 + 1093 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1094 + 1095 + export type FooWowData = { 1096 + body?: never; 1097 + path?: never; 1098 + query?: never; 1099 + url: '/api/v{api-version}/no+tag'; 1100 + }; 1101 + 1102 + export type FooWowResponses = { 1103 + /** 1104 + * OK 1105 + */ 1106 + default: unknown; 1107 + }; 1108 + 1109 + export type ApiVVersionODataControllerCountData = { 1110 + body?: never; 1111 + path?: never; 1112 + query?: never; 1113 + url: '/api/v{api-version}/simple/$count'; 1114 + }; 1115 + 1116 + export type ApiVVersionODataControllerCountResponses = { 1117 + /** 1118 + * Success 1119 + */ 1120 + 200: ModelFromZendesk; 1121 + }; 1122 + 1123 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1124 + 1125 + export type GetApiVbyApiVersionSimpleOperationData = { 1126 + body?: never; 1127 + path: { 1128 + /** 1129 + * foo in method 1130 + */ 1131 + foo_param: string; 1132 + }; 1133 + query?: never; 1134 + url: '/api/v{api-version}/simple:operation'; 1135 + }; 1136 + 1137 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1138 + /** 1139 + * Default error response 1140 + */ 1141 + default: ModelWithBoolean; 1142 + }; 1143 + 1144 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1145 + 1146 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1147 + /** 1148 + * Response is a simple number 1149 + */ 1150 + 200: number; 1151 + }; 1152 + 1153 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1154 + 1155 + export type DeleteCallWithoutParametersAndResponseData = { 1156 + body?: never; 1157 + path?: never; 1158 + query?: never; 1159 + url: '/api/v{api-version}/simple'; 1160 + }; 1161 + 1162 + export type GetCallWithoutParametersAndResponseData = { 1163 + body?: never; 1164 + path?: never; 1165 + query?: never; 1166 + url: '/api/v{api-version}/simple'; 1167 + }; 1168 + 1169 + export type HeadCallWithoutParametersAndResponseData = { 1170 + body?: never; 1171 + path?: never; 1172 + query?: never; 1173 + url: '/api/v{api-version}/simple'; 1174 + }; 1175 + 1176 + export type OptionsCallWithoutParametersAndResponseData = { 1177 + body?: never; 1178 + path?: never; 1179 + query?: never; 1180 + url: '/api/v{api-version}/simple'; 1181 + }; 1182 + 1183 + export type PatchCallWithoutParametersAndResponseData = { 1184 + body?: never; 1185 + path?: never; 1186 + query?: never; 1187 + url: '/api/v{api-version}/simple'; 1188 + }; 1189 + 1190 + export type PostCallWithoutParametersAndResponseData = { 1191 + body?: never; 1192 + path?: never; 1193 + query?: never; 1194 + url: '/api/v{api-version}/simple'; 1195 + }; 1196 + 1197 + export type PutCallWithoutParametersAndResponseData = { 1198 + body?: never; 1199 + path?: never; 1200 + query?: never; 1201 + url: '/api/v{api-version}/simple'; 1202 + }; 1203 + 1204 + export type DeleteFooData3 = { 1205 + body?: never; 1206 + headers: { 1207 + /** 1208 + * Parameter with illegal characters 1209 + */ 1210 + 'x-Foo-Bar': ModelWithString; 1211 + }; 1212 + path: { 1213 + /** 1214 + * foo in method 1215 + */ 1216 + foo_param: string; 1217 + /** 1218 + * bar in method 1219 + */ 1220 + BarParam: string; 1221 + }; 1222 + query?: never; 1223 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1224 + }; 1225 + 1226 + export type CallWithDescriptionsData = { 1227 + body?: never; 1228 + path?: never; 1229 + query?: { 1230 + /** 1231 + * Testing multiline comments in string: First line 1232 + * Second line 1233 + * 1234 + * Fourth line 1235 + */ 1236 + parameterWithBreaks?: string; 1237 + /** 1238 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1239 + */ 1240 + parameterWithBackticks?: string; 1241 + /** 1242 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1243 + */ 1244 + parameterWithSlashes?: string; 1245 + /** 1246 + * Testing expression placeholders in string: ${expression} should work 1247 + */ 1248 + parameterWithExpressionPlaceholders?: string; 1249 + /** 1250 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1251 + */ 1252 + parameterWithQuotes?: string; 1253 + /** 1254 + * Testing reserved characters in string: * inline * and ** inline ** should work 1255 + */ 1256 + parameterWithReservedCharacters?: string; 1257 + }; 1258 + url: '/api/v{api-version}/descriptions'; 1259 + }; 1260 + 1261 + export type DeprecatedCallData = { 1262 + body?: never; 1263 + headers: { 1264 + /** 1265 + * This parameter is deprecated 1266 + * @deprecated 1267 + */ 1268 + parameter: DeprecatedModel | null; 1269 + }; 1270 + path?: never; 1271 + query?: never; 1272 + url: '/api/v{api-version}/parameters/deprecated'; 1273 + }; 1274 + 1275 + export type CallWithParametersData = { 1276 + /** 1277 + * This is the parameter that goes into the body 1278 + */ 1279 + body: { 1280 + [key: string]: unknown; 1281 + } | null; 1282 + headers: { 1283 + /** 1284 + * This is the parameter that goes into the header 1285 + */ 1286 + parameterHeader: string | null; 1287 + }; 1288 + path: { 1289 + /** 1290 + * This is the parameter that goes into the path 1291 + */ 1292 + parameterPath: string | null; 1293 + /** 1294 + * api-version should be required in standalone clients 1295 + */ 1296 + 'api-version': string | null; 1297 + }; 1298 + query: { 1299 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1300 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1301 + /** 1302 + * This is the parameter that goes into the query params 1303 + */ 1304 + cursor: string | null; 1305 + }; 1306 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1307 + }; 1308 + 1309 + export type CallWithWeirdParameterNamesData = { 1310 + /** 1311 + * This is the parameter that goes into the body 1312 + */ 1313 + body: ModelWithString | null; 1314 + headers: { 1315 + /** 1316 + * This is the parameter that goes into the request header 1317 + */ 1318 + 'parameter.header': string | null; 1319 + }; 1320 + path: { 1321 + /** 1322 + * This is the parameter that goes into the path 1323 + */ 1324 + 'parameter.path.1'?: string; 1325 + /** 1326 + * This is the parameter that goes into the path 1327 + */ 1328 + 'parameter-path-2'?: string; 1329 + /** 1330 + * This is the parameter that goes into the path 1331 + */ 1332 + 'PARAMETER-PATH-3'?: string; 1333 + /** 1334 + * api-version should be required in standalone clients 1335 + */ 1336 + 'api-version': string | null; 1337 + }; 1338 + query: { 1339 + /** 1340 + * This is the parameter with a reserved keyword 1341 + */ 1342 + default?: string; 1343 + /** 1344 + * This is the parameter that goes into the request query params 1345 + */ 1346 + 'parameter-query': string | null; 1347 + }; 1348 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1349 + }; 1350 + 1351 + export type GetCallWithOptionalParamData = { 1352 + /** 1353 + * This is a required parameter 1354 + */ 1355 + body: ModelWithOneOfEnum; 1356 + path?: never; 1357 + query?: { 1358 + /** 1359 + * This is an optional parameter 1360 + */ 1361 + page?: number; 1362 + }; 1363 + url: '/api/v{api-version}/parameters'; 1364 + }; 1365 + 1366 + export type PostCallWithOptionalParamData = { 1367 + /** 1368 + * This is an optional parameter 1369 + */ 1370 + body?: { 1371 + offset?: number | null; 1372 + }; 1373 + path?: never; 1374 + query: { 1375 + /** 1376 + * This is a required parameter 1377 + */ 1378 + parameter: Pageable; 1379 + }; 1380 + url: '/api/v{api-version}/parameters'; 1381 + }; 1382 + 1383 + export type PostCallWithOptionalParamResponses = { 1384 + /** 1385 + * Response is a simple number 1386 + */ 1387 + 200: number; 1388 + /** 1389 + * Success 1390 + */ 1391 + 204: void; 1392 + }; 1393 + 1394 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1395 + 1396 + export type PostApiVbyApiVersionRequestBodyData = { 1397 + /** 1398 + * A reusable request body 1399 + */ 1400 + body?: SimpleRequestBody; 1401 + path?: never; 1402 + query?: { 1403 + /** 1404 + * This is a reusable parameter 1405 + */ 1406 + parameter?: string; 1407 + }; 1408 + url: '/api/v{api-version}/requestBody'; 1409 + }; 1410 + 1411 + export type PostApiVbyApiVersionFormDataData = { 1412 + /** 1413 + * A reusable request body 1414 + */ 1415 + body?: SimpleFormData; 1416 + path?: never; 1417 + query?: { 1418 + /** 1419 + * This is a reusable parameter 1420 + */ 1421 + parameter?: string; 1422 + }; 1423 + url: '/api/v{api-version}/formData'; 1424 + }; 1425 + 1426 + export type CallWithDefaultParametersData = { 1427 + body?: never; 1428 + path?: never; 1429 + query?: { 1430 + /** 1431 + * This is a simple string with default value 1432 + */ 1433 + parameterString?: string | null; 1434 + /** 1435 + * This is a simple number with default value 1436 + */ 1437 + parameterNumber?: number | null; 1438 + /** 1439 + * This is a simple boolean with default value 1440 + */ 1441 + parameterBoolean?: boolean | null; 1442 + /** 1443 + * This is a simple enum with default value 1444 + */ 1445 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1446 + /** 1447 + * This is a simple model with default value 1448 + */ 1449 + parameterModel?: ModelWithString | null; 1450 + }; 1451 + url: '/api/v{api-version}/defaults'; 1452 + }; 1453 + 1454 + export type CallWithDefaultOptionalParametersData = { 1455 + body?: never; 1456 + path?: never; 1457 + query?: { 1458 + /** 1459 + * This is a simple string that is optional with default value 1460 + */ 1461 + parameterString?: string; 1462 + /** 1463 + * This is a simple number that is optional with default value 1464 + */ 1465 + parameterNumber?: number; 1466 + /** 1467 + * This is a simple boolean that is optional with default value 1468 + */ 1469 + parameterBoolean?: boolean; 1470 + /** 1471 + * This is a simple enum that is optional with default value 1472 + */ 1473 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1474 + /** 1475 + * This is a simple model that is optional with default value 1476 + */ 1477 + parameterModel?: ModelWithString; 1478 + }; 1479 + url: '/api/v{api-version}/defaults'; 1480 + }; 1481 + 1482 + export type CallToTestOrderOfParamsData = { 1483 + body?: never; 1484 + path?: never; 1485 + query: { 1486 + /** 1487 + * This is a optional string with default 1488 + */ 1489 + parameterOptionalStringWithDefault?: string; 1490 + /** 1491 + * This is a optional string with empty default 1492 + */ 1493 + parameterOptionalStringWithEmptyDefault?: string; 1494 + /** 1495 + * This is a optional string with no default 1496 + */ 1497 + parameterOptionalStringWithNoDefault?: string; 1498 + /** 1499 + * This is a string with default 1500 + */ 1501 + parameterStringWithDefault: string; 1502 + /** 1503 + * This is a string with empty default 1504 + */ 1505 + parameterStringWithEmptyDefault: string; 1506 + /** 1507 + * This is a string with no default 1508 + */ 1509 + parameterStringWithNoDefault: string; 1510 + /** 1511 + * This is a string that can be null with no default 1512 + */ 1513 + parameterStringNullableWithNoDefault?: string | null; 1514 + /** 1515 + * This is a string that can be null with default 1516 + */ 1517 + parameterStringNullableWithDefault?: string | null; 1518 + }; 1519 + url: '/api/v{api-version}/defaults'; 1520 + }; 1521 + 1522 + export type DuplicateNameData = { 1523 + body?: never; 1524 + path?: never; 1525 + query?: never; 1526 + url: '/api/v{api-version}/duplicate'; 1527 + }; 1528 + 1529 + export type DuplicateName2Data = { 1530 + body?: never; 1531 + path?: never; 1532 + query?: never; 1533 + url: '/api/v{api-version}/duplicate'; 1534 + }; 1535 + 1536 + export type DuplicateName3Data = { 1537 + body?: never; 1538 + path?: never; 1539 + query?: never; 1540 + url: '/api/v{api-version}/duplicate'; 1541 + }; 1542 + 1543 + export type DuplicateName4Data = { 1544 + body?: never; 1545 + path?: never; 1546 + query?: never; 1547 + url: '/api/v{api-version}/duplicate'; 1548 + }; 1549 + 1550 + export type CallWithNoContentResponseData = { 1551 + body?: never; 1552 + path?: never; 1553 + query?: never; 1554 + url: '/api/v{api-version}/no-content'; 1555 + }; 1556 + 1557 + export type CallWithNoContentResponseResponses = { 1558 + /** 1559 + * Success 1560 + */ 1561 + 204: void; 1562 + }; 1563 + 1564 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1565 + 1566 + export type CallWithResponseAndNoContentResponseData = { 1567 + body?: never; 1568 + path?: never; 1569 + query?: never; 1570 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1571 + }; 1572 + 1573 + export type CallWithResponseAndNoContentResponseResponses = { 1574 + /** 1575 + * Response is a simple number 1576 + */ 1577 + 200: number; 1578 + /** 1579 + * Success 1580 + */ 1581 + 204: void; 1582 + }; 1583 + 1584 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1585 + 1586 + export type DummyAData = { 1587 + body?: never; 1588 + path?: never; 1589 + query?: never; 1590 + url: '/api/v{api-version}/multiple-tags/a'; 1591 + }; 1592 + 1593 + export type DummyAResponses = { 1594 + 200: _400; 1595 + }; 1596 + 1597 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1598 + 1599 + export type DummyBData = { 1600 + body?: never; 1601 + path?: never; 1602 + query?: never; 1603 + url: '/api/v{api-version}/multiple-tags/b'; 1604 + }; 1605 + 1606 + export type DummyBResponses = { 1607 + /** 1608 + * Success 1609 + */ 1610 + 204: void; 1611 + }; 1612 + 1613 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1614 + 1615 + export type CallWithResponseData = { 1616 + body?: never; 1617 + path?: never; 1618 + query?: never; 1619 + url: '/api/v{api-version}/response'; 1620 + }; 1621 + 1622 + export type CallWithResponseResponses = { 1623 + default: Import; 1624 + }; 1625 + 1626 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1627 + 1628 + export type CallWithDuplicateResponsesData = { 1629 + body?: never; 1630 + path?: never; 1631 + query?: never; 1632 + url: '/api/v{api-version}/response'; 1633 + }; 1634 + 1635 + export type CallWithDuplicateResponsesErrors = { 1636 + /** 1637 + * Message for 500 error 1638 + */ 1639 + 500: ModelWithStringError; 1640 + /** 1641 + * Message for 501 error 1642 + */ 1643 + 501: ModelWithStringError; 1644 + /** 1645 + * Message for 502 error 1646 + */ 1647 + 502: ModelWithStringError; 1648 + /** 1649 + * Message for 4XX errors 1650 + */ 1651 + '4XX': DictionaryWithArray; 1652 + /** 1653 + * Default error response 1654 + */ 1655 + default: ModelWithBoolean; 1656 + }; 1657 + 1658 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1659 + 1660 + export type CallWithDuplicateResponsesResponses = { 1661 + /** 1662 + * Message for 200 response 1663 + */ 1664 + 200: ModelWithBoolean & ModelWithInteger; 1665 + /** 1666 + * Message for 201 response 1667 + */ 1668 + 201: ModelWithString; 1669 + /** 1670 + * Message for 202 response 1671 + */ 1672 + 202: ModelWithString; 1673 + }; 1674 + 1675 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1676 + 1677 + export type CallWithResponsesData = { 1678 + body?: never; 1679 + path?: never; 1680 + query?: never; 1681 + url: '/api/v{api-version}/response'; 1682 + }; 1683 + 1684 + export type CallWithResponsesErrors = { 1685 + /** 1686 + * Message for 500 error 1687 + */ 1688 + 500: ModelWithStringError; 1689 + /** 1690 + * Message for 501 error 1691 + */ 1692 + 501: ModelWithStringError; 1693 + /** 1694 + * Message for 502 error 1695 + */ 1696 + 502: ModelWithStringError; 1697 + /** 1698 + * Message for default response 1699 + */ 1700 + default: ModelWithStringError; 1701 + }; 1702 + 1703 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1704 + 1705 + export type CallWithResponsesResponses = { 1706 + /** 1707 + * Message for 200 response 1708 + */ 1709 + 200: { 1710 + readonly '@namespace.string'?: string; 1711 + readonly '@namespace.integer'?: number; 1712 + readonly value?: Array<ModelWithString>; 1713 + }; 1714 + /** 1715 + * Message for 201 response 1716 + */ 1717 + 201: ModelThatExtends; 1718 + /** 1719 + * Message for 202 response 1720 + */ 1721 + 202: ModelThatExtendsExtends; 1722 + }; 1723 + 1724 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1725 + 1726 + export type CollectionFormatData = { 1727 + body?: never; 1728 + path?: never; 1729 + query: { 1730 + /** 1731 + * This is an array parameter that is sent as csv format (comma-separated values) 1732 + */ 1733 + parameterArrayCSV: Array<string> | null; 1734 + /** 1735 + * This is an array parameter that is sent as ssv format (space-separated values) 1736 + */ 1737 + parameterArraySSV: Array<string> | null; 1738 + /** 1739 + * This is an array parameter that is sent as tsv format (tab-separated values) 1740 + */ 1741 + parameterArrayTSV: Array<string> | null; 1742 + /** 1743 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1744 + */ 1745 + parameterArrayPipes: Array<string> | null; 1746 + /** 1747 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1748 + */ 1749 + parameterArrayMulti: Array<string> | null; 1750 + }; 1751 + url: '/api/v{api-version}/collectionFormat'; 1752 + }; 1753 + 1754 + export type TypesData = { 1755 + body?: never; 1756 + path?: { 1757 + /** 1758 + * This is a number parameter 1759 + */ 1760 + id?: number; 1761 + }; 1762 + query: { 1763 + /** 1764 + * This is a number parameter 1765 + */ 1766 + parameterNumber: number; 1767 + /** 1768 + * This is a string parameter 1769 + */ 1770 + parameterString: string | null; 1771 + /** 1772 + * This is a boolean parameter 1773 + */ 1774 + parameterBoolean: boolean | null; 1775 + /** 1776 + * This is an object parameter 1777 + */ 1778 + parameterObject: { 1779 + [key: string]: unknown; 1780 + } | null; 1781 + /** 1782 + * This is an array parameter 1783 + */ 1784 + parameterArray: Array<string> | null; 1785 + /** 1786 + * This is a dictionary parameter 1787 + */ 1788 + parameterDictionary: { 1789 + [key: string]: unknown; 1790 + } | null; 1791 + /** 1792 + * This is an enum parameter 1793 + */ 1794 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1795 + }; 1796 + url: '/api/v{api-version}/types'; 1797 + }; 1798 + 1799 + export type TypesResponses = { 1800 + /** 1801 + * Response is a simple number 1802 + */ 1803 + 200: number; 1804 + /** 1805 + * Response is a simple string 1806 + */ 1807 + 201: string; 1808 + /** 1809 + * Response is a simple boolean 1810 + */ 1811 + 202: boolean; 1812 + /** 1813 + * Response is a simple object 1814 + */ 1815 + 203: { 1816 + [key: string]: unknown; 1817 + }; 1818 + }; 1819 + 1820 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1821 + 1822 + export type UploadFileData = { 1823 + body: Blob | File; 1824 + path: { 1825 + /** 1826 + * api-version should be required in standalone clients 1827 + */ 1828 + 'api-version': string | null; 1829 + }; 1830 + query?: never; 1831 + url: '/api/v{api-version}/upload'; 1832 + }; 1833 + 1834 + export type UploadFileResponses = { 1835 + 200: boolean; 1836 + }; 1837 + 1838 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1839 + 1840 + export type FileResponseData = { 1841 + body?: never; 1842 + path: { 1843 + id: string; 1844 + /** 1845 + * api-version should be required in standalone clients 1846 + */ 1847 + 'api-version': string; 1848 + }; 1849 + query?: never; 1850 + url: '/api/v{api-version}/file/{id}'; 1851 + }; 1852 + 1853 + export type FileResponseResponses = { 1854 + /** 1855 + * Success 1856 + */ 1857 + 200: Blob | File; 1858 + }; 1859 + 1860 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1861 + 1862 + export type ComplexTypesData = { 1863 + body?: never; 1864 + path?: never; 1865 + query: { 1866 + /** 1867 + * Parameter containing object 1868 + */ 1869 + parameterObject: { 1870 + first?: { 1871 + second?: { 1872 + third?: string; 1873 + }; 1874 + }; 1875 + }; 1876 + /** 1877 + * Parameter containing reference 1878 + */ 1879 + parameterReference: ModelWithString; 1880 + }; 1881 + url: '/api/v{api-version}/complex'; 1882 + }; 1883 + 1884 + export type ComplexTypesErrors = { 1885 + /** 1886 + * 400 `server` error 1887 + */ 1888 + 400: unknown; 1889 + /** 1890 + * 500 server error 1891 + */ 1892 + 500: unknown; 1893 + }; 1894 + 1895 + export type ComplexTypesResponses = { 1896 + /** 1897 + * Successful response 1898 + */ 1899 + 200: Array<ModelWithString>; 1900 + }; 1901 + 1902 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1903 + 1904 + export type MultipartResponseData = { 1905 + body?: never; 1906 + path?: never; 1907 + query?: never; 1908 + url: '/api/v{api-version}/multipart'; 1909 + }; 1910 + 1911 + export type MultipartResponseResponses = { 1912 + /** 1913 + * OK 1914 + */ 1915 + 200: { 1916 + file?: Blob | File; 1917 + metadata?: { 1918 + foo?: string; 1919 + bar?: string; 1920 + }; 1921 + }; 1922 + }; 1923 + 1924 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1925 + 1926 + export type MultipartRequestData = { 1927 + body?: { 1928 + content?: Blob | File; 1929 + data?: ModelWithString | null; 1930 + }; 1931 + path?: never; 1932 + query?: never; 1933 + url: '/api/v{api-version}/multipart'; 1934 + }; 1935 + 1936 + export type ComplexParamsData = { 1937 + body?: { 1938 + readonly key: string | null; 1939 + name: string | null; 1940 + enabled?: boolean; 1941 + type: 'Monkey' | 'Horse' | 'Bird'; 1942 + listOfModels?: Array<ModelWithString> | null; 1943 + listOfStrings?: Array<string> | null; 1944 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1945 + readonly user?: { 1946 + readonly id?: number; 1947 + readonly name?: string | null; 1948 + }; 1949 + }; 1950 + path: { 1951 + id: number; 1952 + /** 1953 + * api-version should be required in standalone clients 1954 + */ 1955 + 'api-version': string; 1956 + }; 1957 + query?: never; 1958 + url: '/api/v{api-version}/complex/{id}'; 1959 + }; 1960 + 1961 + export type ComplexParamsResponses = { 1962 + /** 1963 + * Success 1964 + */ 1965 + 200: ModelWithString; 1966 + }; 1967 + 1968 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1969 + 1970 + export type CallWithResultFromHeaderData = { 1971 + body?: never; 1972 + path?: never; 1973 + query?: never; 1974 + url: '/api/v{api-version}/header'; 1975 + }; 1976 + 1977 + export type CallWithResultFromHeaderErrors = { 1978 + /** 1979 + * 400 server error 1980 + */ 1981 + 400: unknown; 1982 + /** 1983 + * 500 server error 1984 + */ 1985 + 500: unknown; 1986 + }; 1987 + 1988 + export type CallWithResultFromHeaderResponses = { 1989 + /** 1990 + * Successful response 1991 + */ 1992 + 200: unknown; 1993 + }; 1994 + 1995 + export type TestErrorCodeData = { 1996 + body?: never; 1997 + path?: never; 1998 + query: { 1999 + /** 2000 + * Status code to return 2001 + */ 2002 + status: number; 2003 + }; 2004 + url: '/api/v{api-version}/error'; 2005 + }; 2006 + 2007 + export type TestErrorCodeErrors = { 2008 + /** 2009 + * Custom message: Internal Server Error 2010 + */ 2011 + 500: unknown; 2012 + /** 2013 + * Custom message: Not Implemented 2014 + */ 2015 + 501: unknown; 2016 + /** 2017 + * Custom message: Bad Gateway 2018 + */ 2019 + 502: unknown; 2020 + /** 2021 + * Custom message: Service Unavailable 2022 + */ 2023 + 503: unknown; 2024 + }; 2025 + 2026 + export type TestErrorCodeResponses = { 2027 + /** 2028 + * Custom message: Successful response 2029 + */ 2030 + 200: unknown; 2031 + }; 2032 + 2033 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2034 + body?: never; 2035 + path?: never; 2036 + query: { 2037 + /** 2038 + * Dummy input param 2039 + */ 2040 + nonAsciiParamæøåÆØÅöôêÊ: number; 2041 + }; 2042 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2043 + }; 2044 + 2045 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2046 + /** 2047 + * Successful response 2048 + */ 2049 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2050 + }; 2051 + 2052 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2053 + 2054 + export type PutWithFormUrlEncodedData = { 2055 + body: ArrayWithStrings; 2056 + path?: never; 2057 + query?: never; 2058 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2059 + }; 2060 + 2061 + export type ClientOptions = { 2062 + baseURL: 'http://localhost:3000/base' | (string & {}); 2063 + };
+18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ClientOptions } from './types.gen'; 4 + import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions>({ 17 + baseUrl: 'http://localhost:3000/base' 18 + }));
+267
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createSseClient } from '../core/serverSentEvents.gen'; 4 + import type { HttpMethod } from '../core/types.gen'; 5 + import type { 6 + Client, 7 + Config, 8 + RequestOptions, 9 + ResolvedRequestOptions, 10 + } from './types.gen'; 11 + import { 12 + buildUrl, 13 + createConfig, 14 + createInterceptors, 15 + getParseAs, 16 + mergeConfigs, 17 + mergeHeaders, 18 + setAuthParams, 19 + } from './utils.gen'; 20 + 21 + type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 22 + body?: any; 23 + headers: ReturnType<typeof mergeHeaders>; 24 + }; 25 + 26 + export const createClient = (config: Config = {}): Client => { 27 + let _config = mergeConfigs(createConfig(), config); 28 + 29 + const getConfig = (): Config => ({ ..._config }); 30 + 31 + const setConfig = (config: Config): Config => { 32 + _config = mergeConfigs(_config, config); 33 + return getConfig(); 34 + }; 35 + 36 + const interceptors = createInterceptors< 37 + Request, 38 + Response, 39 + unknown, 40 + ResolvedRequestOptions 41 + >(); 42 + 43 + const beforeRequest = async (options: RequestOptions) => { 44 + const opts = { 45 + ..._config, 46 + ...options, 47 + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 48 + headers: mergeHeaders(_config.headers, options.headers), 49 + serializedBody: undefined, 50 + }; 51 + 52 + if (opts.security) { 53 + await setAuthParams({ 54 + ...opts, 55 + security: opts.security, 56 + }); 57 + } 58 + 59 + if (opts.requestValidator) { 60 + await opts.requestValidator(opts); 61 + } 62 + 63 + if (opts.body && opts.bodySerializer) { 64 + opts.serializedBody = opts.bodySerializer(opts.body); 65 + } 66 + 67 + // remove Content-Type header if body is empty to avoid sending invalid requests 68 + if (opts.serializedBody === undefined || opts.serializedBody === '') { 69 + opts.headers.delete('Content-Type'); 70 + } 71 + 72 + const url = buildUrl(opts); 73 + 74 + return { opts, url }; 75 + }; 76 + 77 + const request: Client['request'] = async (options) => { 78 + // @ts-expect-error 79 + const { opts, url } = await beforeRequest(options); 80 + const requestInit: ReqInit = { 81 + redirect: 'follow', 82 + ...opts, 83 + body: opts.serializedBody, 84 + }; 85 + 86 + let request = new Request(url, requestInit); 87 + 88 + for (const fn of interceptors.request._fns) { 89 + if (fn) { 90 + request = await fn(request, opts); 91 + } 92 + } 93 + 94 + // fetch must be assigned here, otherwise it would throw the error: 95 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 96 + const _fetch = opts.fetch!; 97 + let response = await _fetch(request); 98 + 99 + for (const fn of interceptors.response._fns) { 100 + if (fn) { 101 + response = await fn(response, request, opts); 102 + } 103 + } 104 + 105 + const result = { 106 + request, 107 + response, 108 + }; 109 + 110 + if (response.ok) { 111 + const parseAs = 112 + (opts.parseAs === 'auto' 113 + ? getParseAs(response.headers.get('Content-Type')) 114 + : opts.parseAs) ?? 'json'; 115 + 116 + if ( 117 + response.status === 204 || 118 + response.headers.get('Content-Length') === '0' 119 + ) { 120 + let emptyData: any; 121 + switch (parseAs) { 122 + case 'arrayBuffer': 123 + case 'blob': 124 + case 'text': 125 + emptyData = await response[parseAs](); 126 + break; 127 + case 'formData': 128 + emptyData = new FormData(); 129 + break; 130 + case 'stream': 131 + emptyData = response.body; 132 + break; 133 + case 'json': 134 + default: 135 + emptyData = {}; 136 + break; 137 + } 138 + return opts.responseStyle === 'data' 139 + ? emptyData 140 + : { 141 + data: emptyData, 142 + ...result, 143 + }; 144 + } 145 + 146 + let data: any; 147 + switch (parseAs) { 148 + case 'arrayBuffer': 149 + case 'blob': 150 + case 'formData': 151 + case 'json': 152 + case 'text': 153 + data = await response[parseAs](); 154 + break; 155 + case 'stream': 156 + return opts.responseStyle === 'data' 157 + ? response.body 158 + : { 159 + data: response.body, 160 + ...result, 161 + }; 162 + } 163 + 164 + if (parseAs === 'json') { 165 + if (opts.responseValidator) { 166 + await opts.responseValidator(data); 167 + } 168 + 169 + if (opts.responseTransformer) { 170 + data = await opts.responseTransformer(data); 171 + } 172 + } 173 + 174 + return opts.responseStyle === 'data' 175 + ? data 176 + : { 177 + data, 178 + ...result, 179 + }; 180 + } 181 + 182 + const textError = await response.text(); 183 + let jsonError: unknown; 184 + 185 + try { 186 + jsonError = JSON.parse(textError); 187 + } catch { 188 + // noop 189 + } 190 + 191 + const error = jsonError ?? textError; 192 + let finalError = error; 193 + 194 + for (const fn of interceptors.error._fns) { 195 + if (fn) { 196 + finalError = (await fn(error, response, request, opts)) as string; 197 + } 198 + } 199 + 200 + finalError = finalError || ({} as string); 201 + 202 + if (opts.throwOnError) { 203 + throw finalError; 204 + } 205 + 206 + // TODO: we probably want to return error and improve types 207 + return opts.responseStyle === 'data' 208 + ? undefined 209 + : { 210 + error: finalError, 211 + ...result, 212 + }; 213 + }; 214 + 215 + const makeMethodFn = 216 + (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 217 + request({ ...options, method }); 218 + 219 + const makeSseFn = 220 + (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 221 + const { opts, url } = await beforeRequest(options); 222 + return createSseClient({ 223 + ...opts, 224 + body: opts.body as BodyInit | null | undefined, 225 + headers: opts.headers as unknown as Record<string, string>, 226 + method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 236 + url, 237 + }); 238 + }; 239 + 240 + return { 241 + buildUrl, 242 + connect: makeMethodFn('CONNECT'), 243 + delete: makeMethodFn('DELETE'), 244 + get: makeMethodFn('GET'), 245 + getConfig, 246 + head: makeMethodFn('HEAD'), 247 + interceptors, 248 + options: makeMethodFn('OPTIONS'), 249 + patch: makeMethodFn('PATCH'), 250 + post: makeMethodFn('POST'), 251 + put: makeMethodFn('PUT'), 252 + request, 253 + setConfig, 254 + sse: { 255 + connect: makeSseFn('CONNECT'), 256 + delete: makeSseFn('DELETE'), 257 + get: makeSseFn('GET'), 258 + head: makeSseFn('HEAD'), 259 + options: makeSseFn('OPTIONS'), 260 + patch: makeSseFn('PATCH'), 261 + post: makeSseFn('POST'), 262 + put: makeSseFn('PUT'), 263 + trace: makeSseFn('TRACE'), 264 + }, 265 + trace: makeMethodFn('TRACE'), 266 + } as Client; 267 + };
+25
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { createClient } from './client.gen'; 12 + export type { 13 + Client, 14 + ClientOptions, 15 + Config, 16 + CreateClientConfig, 17 + Options, 18 + OptionsLegacyParser, 19 + RequestOptions, 20 + RequestResult, 21 + ResolvedRequestOptions, 22 + ResponseStyle, 23 + TDataShape, 24 + } from './types.gen'; 25 + export { createConfig, mergeHeaders } from './utils.gen';
+268
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth } from '../core/auth.gen'; 4 + import type { 5 + ServerSentEventsOptions, 6 + ServerSentEventsResult, 7 + } from '../core/serverSentEvents.gen'; 8 + import type { 9 + Client as CoreClient, 10 + Config as CoreConfig, 11 + } from '../core/types.gen'; 12 + import type { Middleware } from './utils.gen'; 13 + 14 + export type ResponseStyle = 'data' | 'fields'; 15 + 16 + export interface Config<T extends ClientOptions = ClientOptions> 17 + extends Omit<RequestInit, 'body' | 'headers' | 'method'>, 18 + CoreConfig { 19 + /** 20 + * Base URL for all requests made by this client. 21 + */ 22 + baseUrl?: T['baseUrl']; 23 + /** 24 + * Fetch API implementation. You can use this option to provide a custom 25 + * fetch instance. 26 + * 27 + * @default globalThis.fetch 28 + */ 29 + fetch?: typeof fetch; 30 + /** 31 + * Please don't use the Fetch client for Next.js applications. The `next` 32 + * options won't have any effect. 33 + * 34 + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 35 + */ 36 + next?: never; 37 + /** 38 + * Return the response data parsed in a specified format. By default, `auto` 39 + * will infer the appropriate method from the `Content-Type` response header. 40 + * You can override this behavior with any of the {@link Body} methods. 41 + * Select `stream` if you don't want to parse response data at all. 42 + * 43 + * @default 'auto' 44 + */ 45 + parseAs?: 46 + | 'arrayBuffer' 47 + | 'auto' 48 + | 'blob' 49 + | 'formData' 50 + | 'json' 51 + | 'stream' 52 + | 'text'; 53 + /** 54 + * Should we return only data or multiple fields (data, error, response, etc.)? 55 + * 56 + * @default 'fields' 57 + */ 58 + responseStyle?: ResponseStyle; 59 + /** 60 + * Throw an error instead of returning it in the response? 61 + * 62 + * @default false 63 + */ 64 + throwOnError?: T['throwOnError']; 65 + } 66 + 67 + export interface RequestOptions< 68 + TData = unknown, 69 + TResponseStyle extends ResponseStyle = 'fields', 70 + ThrowOnError extends boolean = boolean, 71 + Url extends string = string, 72 + > extends Config<{ 73 + responseStyle: TResponseStyle; 74 + throwOnError: ThrowOnError; 75 + }>, 76 + Pick< 77 + ServerSentEventsOptions<TData>, 78 + | 'onSseError' 79 + | 'onSseEvent' 80 + | 'sseDefaultRetryDelay' 81 + | 'sseMaxRetryAttempts' 82 + | 'sseMaxRetryDelay' 83 + > { 84 + /** 85 + * Any body that you want to add to your request. 86 + * 87 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 88 + */ 89 + body?: unknown; 90 + path?: Record<string, unknown>; 91 + query?: Record<string, unknown>; 92 + /** 93 + * Security mechanism(s) to use for the request. 94 + */ 95 + security?: ReadonlyArray<Auth>; 96 + url: Url; 97 + } 98 + 99 + export interface ResolvedRequestOptions< 100 + TResponseStyle extends ResponseStyle = 'fields', 101 + ThrowOnError extends boolean = boolean, 102 + Url extends string = string, 103 + > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 104 + serializedBody?: string; 105 + } 106 + 107 + export type RequestResult< 108 + TData = unknown, 109 + TError = unknown, 110 + ThrowOnError extends boolean = boolean, 111 + TResponseStyle extends ResponseStyle = 'fields', 112 + > = ThrowOnError extends true 113 + ? Promise< 114 + TResponseStyle extends 'data' 115 + ? TData extends Record<string, unknown> 116 + ? TData[keyof TData] 117 + : TData 118 + : { 119 + data: TData extends Record<string, unknown> 120 + ? TData[keyof TData] 121 + : TData; 122 + request: Request; 123 + response: Response; 124 + } 125 + > 126 + : Promise< 127 + TResponseStyle extends 'data' 128 + ? 129 + | (TData extends Record<string, unknown> 130 + ? TData[keyof TData] 131 + : TData) 132 + | undefined 133 + : ( 134 + | { 135 + data: TData extends Record<string, unknown> 136 + ? TData[keyof TData] 137 + : TData; 138 + error: undefined; 139 + } 140 + | { 141 + data: undefined; 142 + error: TError extends Record<string, unknown> 143 + ? TError[keyof TError] 144 + : TError; 145 + } 146 + ) & { 147 + request: Request; 148 + response: Response; 149 + } 150 + >; 151 + 152 + export interface ClientOptions { 153 + baseUrl?: string; 154 + responseStyle?: ResponseStyle; 155 + throwOnError?: boolean; 156 + } 157 + 158 + type MethodFn = < 159 + TData = unknown, 160 + TError = unknown, 161 + ThrowOnError extends boolean = false, 162 + TResponseStyle extends ResponseStyle = 'fields', 163 + >( 164 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 165 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 166 + 167 + type SseFn = < 168 + TData = unknown, 169 + TError = unknown, 170 + ThrowOnError extends boolean = false, 171 + TResponseStyle extends ResponseStyle = 'fields', 172 + >( 173 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 174 + ) => Promise<ServerSentEventsResult<TData, TError>>; 175 + 176 + type RequestFn = < 177 + TData = unknown, 178 + TError = unknown, 179 + ThrowOnError extends boolean = false, 180 + TResponseStyle extends ResponseStyle = 'fields', 181 + >( 182 + options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 183 + Pick< 184 + Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 185 + 'method' 186 + >, 187 + ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 188 + 189 + type BuildUrlFn = < 190 + TData extends { 191 + body?: unknown; 192 + path?: Record<string, unknown>; 193 + query?: Record<string, unknown>; 194 + url: string; 195 + }, 196 + >( 197 + options: Pick<TData, 'url'> & Options<TData>, 198 + ) => string; 199 + 200 + export type Client = CoreClient< 201 + RequestFn, 202 + Config, 203 + MethodFn, 204 + BuildUrlFn, 205 + SseFn 206 + > & { 207 + interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 208 + }; 209 + 210 + /** 211 + * The `createClientConfig()` function will be called on client initialization 212 + * and the returned object will become the client's initial configuration. 213 + * 214 + * You may want to initialize your client this way instead of calling 215 + * `setConfig()`. This is useful for example if you're using Next.js 216 + * to ensure your client always has the correct values. 217 + */ 218 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 219 + override?: Config<ClientOptions & T>, 220 + ) => Config<Required<ClientOptions> & T>; 221 + 222 + export interface TDataShape { 223 + body?: unknown; 224 + headers?: unknown; 225 + path?: unknown; 226 + query?: unknown; 227 + url: string; 228 + } 229 + 230 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 231 + 232 + export type Options< 233 + TData extends TDataShape = TDataShape, 234 + ThrowOnError extends boolean = boolean, 235 + TResponse = unknown, 236 + TResponseStyle extends ResponseStyle = 'fields', 237 + > = OmitKeys< 238 + RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 239 + 'body' | 'path' | 'query' | 'url' 240 + > & 241 + Omit<TData, 'url'>; 242 + 243 + export type OptionsLegacyParser< 244 + TData = unknown, 245 + ThrowOnError extends boolean = boolean, 246 + TResponseStyle extends ResponseStyle = 'fields', 247 + > = TData extends { body?: any } 248 + ? TData extends { headers?: any } 249 + ? OmitKeys< 250 + RequestOptions<unknown, TResponseStyle, ThrowOnError>, 251 + 'body' | 'headers' | 'url' 252 + > & 253 + TData 254 + : OmitKeys< 255 + RequestOptions<unknown, TResponseStyle, ThrowOnError>, 256 + 'body' | 'url' 257 + > & 258 + TData & 259 + Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'headers'> 260 + : TData extends { headers?: any } 261 + ? OmitKeys< 262 + RequestOptions<unknown, TResponseStyle, ThrowOnError>, 263 + 'headers' | 'url' 264 + > & 265 + TData & 266 + Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'body'> 267 + : OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'url'> & 268 + TData;
+327
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 + import { 7 + serializeArrayParam, 8 + serializeObjectParam, 9 + serializePrimitiveParam, 10 + } from '../core/pathSerializer.gen'; 11 + import { getUrl } from '../core/utils.gen'; 12 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 + 14 + export const createQuerySerializer = <T = unknown>({ 15 + allowReserved, 16 + array, 17 + object, 18 + }: QuerySerializerOptions = {}) => { 19 + const querySerializer = (queryParams: T) => { 20 + const search: string[] = []; 21 + if (queryParams && typeof queryParams === 'object') { 22 + for (const name in queryParams) { 23 + const value = queryParams[name]; 24 + 25 + if (value === undefined || value === null) { 26 + continue; 27 + } 28 + 29 + if (Array.isArray(value)) { 30 + const serializedArray = serializeArrayParam({ 31 + allowReserved, 32 + explode: true, 33 + name, 34 + style: 'form', 35 + value, 36 + ...array, 37 + }); 38 + if (serializedArray) search.push(serializedArray); 39 + } else if (typeof value === 'object') { 40 + const serializedObject = serializeObjectParam({ 41 + allowReserved, 42 + explode: true, 43 + name, 44 + style: 'deepObject', 45 + value: value as Record<string, unknown>, 46 + ...object, 47 + }); 48 + if (serializedObject) search.push(serializedObject); 49 + } else { 50 + const serializedPrimitive = serializePrimitiveParam({ 51 + allowReserved, 52 + name, 53 + value: value as string, 54 + }); 55 + if (serializedPrimitive) search.push(serializedPrimitive); 56 + } 57 + } 58 + } 59 + return search.join('&'); 60 + }; 61 + return querySerializer; 62 + }; 63 + 64 + /** 65 + * Infers parseAs value from provided Content-Type header. 66 + */ 67 + export const getParseAs = ( 68 + contentType: string | null, 69 + ): Exclude<Config['parseAs'], 'auto'> => { 70 + if (!contentType) { 71 + // If no Content-Type header is provided, the best we can do is return the raw response body, 72 + // which is effectively the same as the 'stream' option. 73 + return 'stream'; 74 + } 75 + 76 + const cleanContent = contentType.split(';')[0]?.trim(); 77 + 78 + if (!cleanContent) { 79 + return; 80 + } 81 + 82 + if ( 83 + cleanContent.startsWith('application/json') || 84 + cleanContent.endsWith('+json') 85 + ) { 86 + return 'json'; 87 + } 88 + 89 + if (cleanContent === 'multipart/form-data') { 90 + return 'formData'; 91 + } 92 + 93 + if ( 94 + ['application/', 'audio/', 'image/', 'video/'].some((type) => 95 + cleanContent.startsWith(type), 96 + ) 97 + ) { 98 + return 'blob'; 99 + } 100 + 101 + if (cleanContent.startsWith('text/')) { 102 + return 'text'; 103 + } 104 + 105 + return; 106 + }; 107 + 108 + const checkForExistence = ( 109 + options: Pick<RequestOptions, 'auth' | 'query'> & { 110 + headers: Headers; 111 + }, 112 + name?: string, 113 + ): boolean => { 114 + if (!name) { 115 + return false; 116 + } 117 + if ( 118 + options.headers.has(name) || 119 + options.query?.[name] || 120 + options.headers.get('Cookie')?.includes(`${name}=`) 121 + ) { 122 + return true; 123 + } 124 + return false; 125 + }; 126 + 127 + export const setAuthParams = async ({ 128 + security, 129 + ...options 130 + }: Pick<Required<RequestOptions>, 'security'> & 131 + Pick<RequestOptions, 'auth' | 'query'> & { 132 + headers: Headers; 133 + }) => { 134 + for (const auth of security) { 135 + if (checkForExistence(options, auth.name)) { 136 + continue; 137 + } 138 + 139 + const token = await getAuthToken(auth, options.auth); 140 + 141 + if (!token) { 142 + continue; 143 + } 144 + 145 + const name = auth.name ?? 'Authorization'; 146 + 147 + switch (auth.in) { 148 + case 'query': 149 + if (!options.query) { 150 + options.query = {}; 151 + } 152 + options.query[name] = token; 153 + break; 154 + case 'cookie': 155 + options.headers.append('Cookie', `${name}=${token}`); 156 + break; 157 + case 'header': 158 + default: 159 + options.headers.set(name, token); 160 + break; 161 + } 162 + } 163 + }; 164 + 165 + export const buildUrl: Client['buildUrl'] = (options) => 166 + getUrl({ 167 + baseUrl: options.baseUrl as string, 168 + path: options.path, 169 + query: options.query, 170 + querySerializer: 171 + typeof options.querySerializer === 'function' 172 + ? options.querySerializer 173 + : createQuerySerializer(options.querySerializer), 174 + url: options.url, 175 + }); 176 + 177 + export const mergeConfigs = (a: Config, b: Config): Config => { 178 + const config = { ...a, ...b }; 179 + if (config.baseUrl?.endsWith('/')) { 180 + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 181 + } 182 + config.headers = mergeHeaders(a.headers, b.headers); 183 + return config; 184 + }; 185 + 186 + export const mergeHeaders = ( 187 + ...headers: Array<Required<Config>['headers'] | undefined> 188 + ): Headers => { 189 + const mergedHeaders = new Headers(); 190 + for (const header of headers) { 191 + if (!header || typeof header !== 'object') { 192 + continue; 193 + } 194 + 195 + const iterator = 196 + header instanceof Headers ? header.entries() : Object.entries(header); 197 + 198 + for (const [key, value] of iterator) { 199 + if (value === null) { 200 + mergedHeaders.delete(key); 201 + } else if (Array.isArray(value)) { 202 + for (const v of value) { 203 + mergedHeaders.append(key, v as string); 204 + } 205 + } else if (value !== undefined) { 206 + // assume object headers are meant to be JSON stringified, i.e. their 207 + // content value in OpenAPI specification is 'application/json' 208 + mergedHeaders.set( 209 + key, 210 + typeof value === 'object' ? JSON.stringify(value) : (value as string), 211 + ); 212 + } 213 + } 214 + } 215 + return mergedHeaders; 216 + }; 217 + 218 + type ErrInterceptor<Err, Res, Req, Options> = ( 219 + error: Err, 220 + response: Res, 221 + request: Req, 222 + options: Options, 223 + ) => Err | Promise<Err>; 224 + 225 + type ReqInterceptor<Req, Options> = ( 226 + request: Req, 227 + options: Options, 228 + ) => Req | Promise<Req>; 229 + 230 + type ResInterceptor<Res, Req, Options> = ( 231 + response: Res, 232 + request: Req, 233 + options: Options, 234 + ) => Res | Promise<Res>; 235 + 236 + class Interceptors<Interceptor> { 237 + _fns: (Interceptor | null)[]; 238 + 239 + constructor() { 240 + this._fns = []; 241 + } 242 + 243 + clear() { 244 + this._fns = []; 245 + } 246 + 247 + getInterceptorIndex(id: number | Interceptor): number { 248 + if (typeof id === 'number') { 249 + return this._fns[id] ? id : -1; 250 + } else { 251 + return this._fns.indexOf(id); 252 + } 253 + } 254 + exists(id: number | Interceptor) { 255 + const index = this.getInterceptorIndex(id); 256 + return !!this._fns[index]; 257 + } 258 + 259 + eject(id: number | Interceptor) { 260 + const index = this.getInterceptorIndex(id); 261 + if (this._fns[index]) { 262 + this._fns[index] = null; 263 + } 264 + } 265 + 266 + update(id: number | Interceptor, fn: Interceptor) { 267 + const index = this.getInterceptorIndex(id); 268 + if (this._fns[index]) { 269 + this._fns[index] = fn; 270 + return id; 271 + } else { 272 + return false; 273 + } 274 + } 275 + 276 + use(fn: Interceptor) { 277 + this._fns = [...this._fns, fn]; 278 + return this._fns.length - 1; 279 + } 280 + } 281 + 282 + // `createInterceptors()` response, meant for external use as it does not 283 + // expose internals 284 + export interface Middleware<Req, Res, Err, Options> { 285 + error: Pick< 286 + Interceptors<ErrInterceptor<Err, Res, Req, Options>>, 287 + 'eject' | 'use' 288 + >; 289 + request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>; 290 + response: Pick< 291 + Interceptors<ResInterceptor<Res, Req, Options>>, 292 + 'eject' | 'use' 293 + >; 294 + } 295 + 296 + // do not add `Middleware` as return type so we can use _fns internally 297 + export const createInterceptors = <Req, Res, Err, Options>() => ({ 298 + error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 299 + request: new Interceptors<ReqInterceptor<Req, Options>>(), 300 + response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 301 + }); 302 + 303 + const defaultQuerySerializer = createQuerySerializer({ 304 + allowReserved: false, 305 + array: { 306 + explode: true, 307 + style: 'form', 308 + }, 309 + object: { 310 + explode: true, 311 + style: 'deepObject', 312 + }, 313 + }); 314 + 315 + const defaultHeaders = { 316 + 'Content-Type': 'application/json', 317 + }; 318 + 319 + export const createConfig = <T extends ClientOptions = ClientOptions>( 320 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 321 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 322 + ...jsonBodySerializer, 323 + headers: defaultHeaders, 324 + parseAs: 'auto', 325 + querySerializer: defaultQuerySerializer, 326 + ...override, 327 + });
+42
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = 27 + typeof callback === 'function' ? await callback(auth) : callback; 28 + 29 + if (!token) { 30 + return; 31 + } 32 + 33 + if (auth.scheme === 'bearer') { 34 + return `Bearer ${token}`; 35 + } 36 + 37 + if (auth.scheme === 'basic') { 38 + return `Basic ${btoa(token)}`; 39 + } 40 + 41 + return token; 42 + };
+92
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + ArrayStyle, 5 + ObjectStyle, 6 + SerializerOptions, 7 + } from './pathSerializer.gen'; 8 + 9 + export type QuerySerializer = (query: Record<string, unknown>) => string; 10 + 11 + export type BodySerializer = (body: any) => any; 12 + 13 + export interface QuerySerializerOptions { 14 + allowReserved?: boolean; 15 + array?: SerializerOptions<ArrayStyle>; 16 + object?: SerializerOptions<ObjectStyle>; 17 + } 18 + 19 + const serializeFormDataPair = ( 20 + data: FormData, 21 + key: string, 22 + value: unknown, 23 + ): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = ( 34 + data: URLSearchParams, 35 + key: string, 36 + value: unknown, 37 + ): void => { 38 + if (typeof value === 'string') { 39 + data.append(key, value); 40 + } else { 41 + data.append(key, JSON.stringify(value)); 42 + } 43 + }; 44 + 45 + export const formDataBodySerializer = { 46 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 47 + body: T, 48 + ): FormData => { 49 + const data = new FormData(); 50 + 51 + Object.entries(body).forEach(([key, value]) => { 52 + if (value === undefined || value === null) { 53 + return; 54 + } 55 + if (Array.isArray(value)) { 56 + value.forEach((v) => serializeFormDataPair(data, key, v)); 57 + } else { 58 + serializeFormDataPair(data, key, value); 59 + } 60 + }); 61 + 62 + return data; 63 + }, 64 + }; 65 + 66 + export const jsonBodySerializer = { 67 + bodySerializer: <T>(body: T): string => 68 + JSON.stringify(body, (_key, value) => 69 + typeof value === 'bigint' ? value.toString() : value, 70 + ), 71 + }; 72 + 73 + export const urlSearchParamsBodySerializer = { 74 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 75 + body: T, 76 + ): string => { 77 + const data = new URLSearchParams(); 78 + 79 + Object.entries(body).forEach(([key, value]) => { 80 + if (value === undefined || value === null) { 81 + return; 82 + } 83 + if (Array.isArray(value)) { 84 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 85 + } else { 86 + serializeUrlSearchParamsPair(data, key, value); 87 + } 88 + }); 89 + 90 + return data.toString(); 91 + }, 92 + };
+153
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + }; 26 + 27 + export interface Fields { 28 + allowExtra?: Partial<Record<Slot, boolean>>; 29 + args?: ReadonlyArray<Field>; 30 + } 31 + 32 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 33 + 34 + const extraPrefixesMap: Record<string, Slot> = { 35 + $body_: 'body', 36 + $headers_: 'headers', 37 + $path_: 'path', 38 + $query_: 'query', 39 + }; 40 + const extraPrefixes = Object.entries(extraPrefixesMap); 41 + 42 + type KeyMap = Map< 43 + string, 44 + { 45 + in: Slot; 46 + map?: string; 47 + } 48 + >; 49 + 50 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 51 + if (!map) { 52 + map = new Map(); 53 + } 54 + 55 + for (const config of fields) { 56 + if ('in' in config) { 57 + if (config.key) { 58 + map.set(config.key, { 59 + in: config.in, 60 + map: config.map, 61 + }); 62 + } 63 + } else if (config.args) { 64 + buildKeyMap(config.args, map); 65 + } 66 + } 67 + 68 + return map; 69 + }; 70 + 71 + interface Params { 72 + body: unknown; 73 + headers: Record<string, unknown>; 74 + path: Record<string, unknown>; 75 + query: Record<string, unknown>; 76 + } 77 + 78 + const stripEmptySlots = (params: Params) => { 79 + for (const [slot, value] of Object.entries(params)) { 80 + if (value && typeof value === 'object' && !Object.keys(value).length) { 81 + delete params[slot as Slot]; 82 + } 83 + } 84 + }; 85 + 86 + export const buildClientParams = ( 87 + args: ReadonlyArray<unknown>, 88 + fields: FieldsConfig, 89 + ) => { 90 + const params: Params = { 91 + body: {}, 92 + headers: {}, 93 + path: {}, 94 + query: {}, 95 + }; 96 + 97 + const map = buildKeyMap(fields); 98 + 99 + let config: FieldsConfig[number] | undefined; 100 + 101 + for (const [index, arg] of args.entries()) { 102 + if (fields[index]) { 103 + config = fields[index]; 104 + } 105 + 106 + if (!config) { 107 + continue; 108 + } 109 + 110 + if ('in' in config) { 111 + if (config.key) { 112 + const field = map.get(config.key)!; 113 + const name = field.map || config.key; 114 + (params[field.in] as Record<string, unknown>)[name] = arg; 115 + } else { 116 + params.body = arg; 117 + } 118 + } else { 119 + for (const [key, value] of Object.entries(arg ?? {})) { 120 + const field = map.get(key); 121 + 122 + if (field) { 123 + const name = field.map || key; 124 + (params[field.in] as Record<string, unknown>)[name] = value; 125 + } else { 126 + const extra = extraPrefixes.find(([prefix]) => 127 + key.startsWith(prefix), 128 + ); 129 + 130 + if (extra) { 131 + const [prefix, slot] = extra; 132 + (params[slot] as Record<string, unknown>)[ 133 + key.slice(prefix.length) 134 + ] = value; 135 + } else { 136 + for (const [slot, allowed] of Object.entries( 137 + config.allowExtra ?? {}, 138 + )) { 139 + if (allowed) { 140 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 141 + break; 142 + } 143 + } 144 + } 145 + } 146 + } 147 + } 148 + } 149 + 150 + stripEmptySlots(params); 151 + 152 + return params; 153 + };
+181
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> 4 + extends SerializePrimitiveOptions, 5 + SerializerOptions<T> {} 6 + 7 + interface SerializePrimitiveOptions { 8 + allowReserved?: boolean; 9 + name: string; 10 + } 11 + 12 + export interface SerializerOptions<T> { 13 + /** 14 + * @default true 15 + */ 16 + explode: boolean; 17 + style: T; 18 + } 19 + 20 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 21 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 22 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 23 + export type ObjectStyle = 'form' | 'deepObject'; 24 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 25 + 26 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 27 + value: string; 28 + } 29 + 30 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 31 + switch (style) { 32 + case 'label': 33 + return '.'; 34 + case 'matrix': 35 + return ';'; 36 + case 'simple': 37 + return ','; 38 + default: 39 + return '&'; 40 + } 41 + }; 42 + 43 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 44 + switch (style) { 45 + case 'form': 46 + return ','; 47 + case 'pipeDelimited': 48 + return '|'; 49 + case 'spaceDelimited': 50 + return '%20'; 51 + default: 52 + return ','; 53 + } 54 + }; 55 + 56 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 57 + switch (style) { 58 + case 'label': 59 + return '.'; 60 + case 'matrix': 61 + return ';'; 62 + case 'simple': 63 + return ','; 64 + default: 65 + return '&'; 66 + } 67 + }; 68 + 69 + export const serializeArrayParam = ({ 70 + allowReserved, 71 + explode, 72 + name, 73 + style, 74 + value, 75 + }: SerializeOptions<ArraySeparatorStyle> & { 76 + value: unknown[]; 77 + }) => { 78 + if (!explode) { 79 + const joinedValues = ( 80 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 81 + ).join(separatorArrayNoExplode(style)); 82 + switch (style) { 83 + case 'label': 84 + return `.${joinedValues}`; 85 + case 'matrix': 86 + return `;${name}=${joinedValues}`; 87 + case 'simple': 88 + return joinedValues; 89 + default: 90 + return `${name}=${joinedValues}`; 91 + } 92 + } 93 + 94 + const separator = separatorArrayExplode(style); 95 + const joinedValues = value 96 + .map((v) => { 97 + if (style === 'label' || style === 'simple') { 98 + return allowReserved ? v : encodeURIComponent(v as string); 99 + } 100 + 101 + return serializePrimitiveParam({ 102 + allowReserved, 103 + name, 104 + value: v as string, 105 + }); 106 + }) 107 + .join(separator); 108 + return style === 'label' || style === 'matrix' 109 + ? separator + joinedValues 110 + : joinedValues; 111 + }; 112 + 113 + export const serializePrimitiveParam = ({ 114 + allowReserved, 115 + name, 116 + value, 117 + }: SerializePrimitiveParam) => { 118 + if (value === undefined || value === null) { 119 + return ''; 120 + } 121 + 122 + if (typeof value === 'object') { 123 + throw new Error( 124 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 125 + ); 126 + } 127 + 128 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 129 + }; 130 + 131 + export const serializeObjectParam = ({ 132 + allowReserved, 133 + explode, 134 + name, 135 + style, 136 + value, 137 + valueOnly, 138 + }: SerializeOptions<ObjectSeparatorStyle> & { 139 + value: Record<string, unknown> | Date; 140 + valueOnly?: boolean; 141 + }) => { 142 + if (value instanceof Date) { 143 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 144 + } 145 + 146 + if (style !== 'deepObject' && !explode) { 147 + let values: string[] = []; 148 + Object.entries(value).forEach(([key, v]) => { 149 + values = [ 150 + ...values, 151 + key, 152 + allowReserved ? (v as string) : encodeURIComponent(v as string), 153 + ]; 154 + }); 155 + const joinedValues = values.join(','); 156 + switch (style) { 157 + case 'form': 158 + return `${name}=${joinedValues}`; 159 + case 'label': 160 + return `.${joinedValues}`; 161 + case 'matrix': 162 + return `;${name}=${joinedValues}`; 163 + default: 164 + return joinedValues; 165 + } 166 + } 167 + 168 + const separator = separatorObjectExplode(style); 169 + const joinedValues = Object.entries(value) 170 + .map(([key, v]) => 171 + serializePrimitiveParam({ 172 + allowReserved, 173 + name: style === 'deepObject' ? `${name}[${key}]` : key, 174 + value: v as string, 175 + }), 176 + ) 177 + .join(separator); 178 + return style === 'label' || style === 'matrix' 179 + ? separator + joinedValues 180 + : joinedValues; 181 + };
+264
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit< 6 + RequestInit, 7 + 'method' 8 + > & 9 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 + /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 22 + * Callback invoked when a network or parsing error occurs during streaming. 23 + * 24 + * This option applies only if the endpoint returns a stream of events. 25 + * 26 + * @param error The error that occurred. 27 + */ 28 + onSseError?: (error: unknown) => void; 29 + /** 30 + * Callback invoked when an event is streamed from the server. 31 + * 32 + * This option applies only if the endpoint returns a stream of events. 33 + * 34 + * @param event Event streamed from the server. 35 + * @returns Nothing (void). 36 + */ 37 + onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 39 + /** 40 + * Default retry delay in milliseconds. 41 + * 42 + * This option applies only if the endpoint returns a stream of events. 43 + * 44 + * @default 3000 45 + */ 46 + sseDefaultRetryDelay?: number; 47 + /** 48 + * Maximum number of retry attempts before giving up. 49 + */ 50 + sseMaxRetryAttempts?: number; 51 + /** 52 + * Maximum retry delay in milliseconds. 53 + * 54 + * Applies only when exponential backoff is used. 55 + * 56 + * This option applies only if the endpoint returns a stream of events. 57 + * 58 + * @default 30000 59 + */ 60 + sseMaxRetryDelay?: number; 61 + /** 62 + * Optional sleep function for retry backoff. 63 + * 64 + * Defaults to using `setTimeout`. 65 + */ 66 + sseSleepFn?: (ms: number) => Promise<void>; 67 + url: string; 68 + }; 69 + 70 + export interface StreamEvent<TData = unknown> { 71 + data: TData; 72 + event?: string; 73 + id?: string; 74 + retry?: number; 75 + } 76 + 77 + export type ServerSentEventsResult< 78 + TData = unknown, 79 + TReturn = void, 80 + TNext = unknown, 81 + > = { 82 + stream: AsyncGenerator< 83 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 84 + TReturn, 85 + TNext 86 + >; 87 + }; 88 + 89 + export const createSseClient = <TData = unknown>({ 90 + onRequest, 91 + onSseError, 92 + onSseEvent, 93 + responseTransformer, 94 + responseValidator, 95 + sseDefaultRetryDelay, 96 + sseMaxRetryAttempts, 97 + sseMaxRetryDelay, 98 + sseSleepFn, 99 + url, 100 + ...options 101 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 102 + let lastEventId: string | undefined; 103 + 104 + const sleep = 105 + sseSleepFn ?? 106 + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 107 + 108 + const createStream = async function* () { 109 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 110 + let attempt = 0; 111 + const signal = options.signal ?? new AbortController().signal; 112 + 113 + while (true) { 114 + if (signal.aborted) break; 115 + 116 + attempt++; 117 + 118 + const headers = 119 + options.headers instanceof Headers 120 + ? options.headers 121 + : new Headers(options.headers as Record<string, string> | undefined); 122 + 123 + if (lastEventId !== undefined) { 124 + headers.set('Last-Event-ID', lastEventId); 125 + } 126 + 127 + try { 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 143 + 144 + if (!response.ok) 145 + throw new Error( 146 + `SSE failed: ${response.status} ${response.statusText}`, 147 + ); 148 + 149 + if (!response.body) throw new Error('No body in SSE response'); 150 + 151 + const reader = response.body 152 + .pipeThrough(new TextDecoderStream()) 153 + .getReader(); 154 + 155 + let buffer = ''; 156 + 157 + const abortHandler = () => { 158 + try { 159 + reader.cancel(); 160 + } catch { 161 + // noop 162 + } 163 + }; 164 + 165 + signal.addEventListener('abort', abortHandler); 166 + 167 + try { 168 + while (true) { 169 + const { done, value } = await reader.read(); 170 + if (done) break; 171 + buffer += value; 172 + 173 + const chunks = buffer.split('\n\n'); 174 + buffer = chunks.pop() ?? ''; 175 + 176 + for (const chunk of chunks) { 177 + const lines = chunk.split('\n'); 178 + const dataLines: Array<string> = []; 179 + let eventName: string | undefined; 180 + 181 + for (const line of lines) { 182 + if (line.startsWith('data:')) { 183 + dataLines.push(line.replace(/^data:\s*/, '')); 184 + } else if (line.startsWith('event:')) { 185 + eventName = line.replace(/^event:\s*/, ''); 186 + } else if (line.startsWith('id:')) { 187 + lastEventId = line.replace(/^id:\s*/, ''); 188 + } else if (line.startsWith('retry:')) { 189 + const parsed = Number.parseInt( 190 + line.replace(/^retry:\s*/, ''), 191 + 10, 192 + ); 193 + if (!Number.isNaN(parsed)) { 194 + retryDelay = parsed; 195 + } 196 + } 197 + } 198 + 199 + let data: unknown; 200 + let parsedJson = false; 201 + 202 + if (dataLines.length) { 203 + const rawData = dataLines.join('\n'); 204 + try { 205 + data = JSON.parse(rawData); 206 + parsedJson = true; 207 + } catch { 208 + data = rawData; 209 + } 210 + } 211 + 212 + if (parsedJson) { 213 + if (responseValidator) { 214 + await responseValidator(data); 215 + } 216 + 217 + if (responseTransformer) { 218 + data = await responseTransformer(data); 219 + } 220 + } 221 + 222 + onSseEvent?.({ 223 + data, 224 + event: eventName, 225 + id: lastEventId, 226 + retry: retryDelay, 227 + }); 228 + 229 + if (dataLines.length) { 230 + yield data as any; 231 + } 232 + } 233 + } 234 + } finally { 235 + signal.removeEventListener('abort', abortHandler); 236 + reader.releaseLock(); 237 + } 238 + 239 + break; // exit loop on normal completion 240 + } catch (error) { 241 + // connection failed or aborted; retry after delay 242 + onSseError?.(error); 243 + 244 + if ( 245 + sseMaxRetryAttempts !== undefined && 246 + attempt >= sseMaxRetryAttempts 247 + ) { 248 + break; // stop after firing error 249 + } 250 + 251 + // exponential backoff: double retry each attempt, cap at 30s 252 + const backoff = Math.min( 253 + retryDelay * 2 ** (attempt - 1), 254 + sseMaxRetryDelay ?? 30000, 255 + ); 256 + await sleep(backoff); 257 + } 258 + } 259 + }; 260 + 261 + const stream = createStream(); 262 + 263 + return { stream }; 264 + };
+118
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { 5 + BodySerializer, 6 + QuerySerializer, 7 + QuerySerializerOptions, 8 + } from './bodySerializer.gen'; 9 + 10 + export type HttpMethod = 11 + | 'connect' 12 + | 'delete' 13 + | 'get' 14 + | 'head' 15 + | 'options' 16 + | 'patch' 17 + | 'post' 18 + | 'put' 19 + | 'trace'; 20 + 21 + export type Client< 22 + RequestFn = never, 23 + Config = unknown, 24 + MethodFn = never, 25 + BuildUrlFn = never, 26 + SseFn = never, 27 + > = { 28 + /** 29 + * Returns the final request URL. 30 + */ 31 + buildUrl: BuildUrlFn; 32 + getConfig: () => Config; 33 + request: RequestFn; 34 + setConfig: (config: Config) => Config; 35 + } & { 36 + [K in HttpMethod]: MethodFn; 37 + } & ([SseFn] extends [never] 38 + ? { sse?: never } 39 + : { sse: { [K in HttpMethod]: SseFn } }); 40 + 41 + export interface Config { 42 + /** 43 + * Auth token or a function returning auth token. The resolved value will be 44 + * added to the request payload as defined by its `security` array. 45 + */ 46 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 47 + /** 48 + * A function for serializing request body parameter. By default, 49 + * {@link JSON.stringify()} will be used. 50 + */ 51 + bodySerializer?: BodySerializer | null; 52 + /** 53 + * An object containing any HTTP headers that you want to pre-populate your 54 + * `Headers` object with. 55 + * 56 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 57 + */ 58 + headers?: 59 + | RequestInit['headers'] 60 + | Record< 61 + string, 62 + | string 63 + | number 64 + | boolean 65 + | (string | number | boolean)[] 66 + | null 67 + | undefined 68 + | unknown 69 + >; 70 + /** 71 + * The request method. 72 + * 73 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 74 + */ 75 + method?: Uppercase<HttpMethod>; 76 + /** 77 + * A function for serializing request query parameters. By default, arrays 78 + * will be exploded in form style, objects will be exploded in deepObject 79 + * style, and reserved characters are percent-encoded. 80 + * 81 + * This method will have no effect if the native `paramsSerializer()` Axios 82 + * API function is used. 83 + * 84 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 85 + */ 86 + querySerializer?: QuerySerializer | QuerySerializerOptions; 87 + /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 94 + * A function transforming response data before it's returned. This is useful 95 + * for post-processing data, e.g. converting ISO strings into Date objects. 96 + */ 97 + responseTransformer?: (data: unknown) => Promise<unknown>; 98 + /** 99 + * A function validating response data. This is useful if you want to ensure 100 + * the response conforms to the desired shape, so it can be safely passed to 101 + * the transformers and returned to the user. 102 + */ 103 + responseValidator?: (data: unknown) => Promise<unknown>; 104 + } 105 + 106 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 107 + ? true 108 + : [T] extends [never | undefined] 109 + ? [undefined] extends [T] 110 + ? false 111 + : true 112 + : false; 113 + 114 + export type OmitNever<T extends Record<string, unknown>> = { 115 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true 116 + ? never 117 + : K]: T[K]; 118 + };
+114
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace( 48 + match, 49 + serializeArrayParam({ explode, name, style, value }), 50 + ); 51 + continue; 52 + } 53 + 54 + if (typeof value === 'object') { 55 + url = url.replace( 56 + match, 57 + serializeObjectParam({ 58 + explode, 59 + name, 60 + style, 61 + value: value as Record<string, unknown>, 62 + valueOnly: true, 63 + }), 64 + ); 65 + continue; 66 + } 67 + 68 + if (style === 'matrix') { 69 + url = url.replace( 70 + match, 71 + `;${serializePrimitiveParam({ 72 + name, 73 + value: value as string, 74 + })}`, 75 + ); 76 + continue; 77 + } 78 + 79 + const replaceValue = encodeURIComponent( 80 + style === 'label' ? `.${value as string}` : (value as string), 81 + ); 82 + url = url.replace(match, replaceValue); 83 + } 84 + } 85 + return url; 86 + }; 87 + 88 + export const getUrl = ({ 89 + baseUrl, 90 + path, 91 + query, 92 + querySerializer, 93 + url: _url, 94 + }: { 95 + baseUrl?: string; 96 + path?: Record<string, unknown>; 97 + query?: Record<string, unknown>; 98 + querySerializer: QuerySerializer; 99 + url: string; 100 + }) => { 101 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 102 + let url = (baseUrl ?? '') + pathUrl; 103 + if (path) { 104 + url = defaultPathSerializer({ path, url }); 105 + } 106 + let search = query ? querySerializer(query) : ''; 107 + if (search.startsWith('?')) { 108 + search = search.substring(1); 109 + } 110 + if (search) { 111 + url += `?${search}`; 112 + } 113 + return url; 114 + };
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './sdk.gen';
+409
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; 4 + 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'; 5 + import { client as _heyApiClient } from './client.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => { 22 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 23 + url: '/api/v{api-version}/no+tag', 24 + ...options 25 + }); 26 + }; 27 + 28 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => { 29 + return (options?.client ?? _heyApiClient).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ 30 + url: '/api/v{api-version}/no+tag', 31 + ...options 32 + }); 33 + }; 34 + 35 + export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => { 36 + return (options.client ?? _heyApiClient).post<ImportResponses, unknown, ThrowOnError>({ 37 + url: '/api/v{api-version}/no+tag', 38 + ...options, 39 + headers: { 40 + 'Content-Type': 'application/json', 41 + ...options.headers 42 + } 43 + }); 44 + }; 45 + 46 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => { 47 + return (options?.client ?? _heyApiClient).put<FooWowResponses, unknown, ThrowOnError>({ 48 + url: '/api/v{api-version}/no+tag', 49 + ...options 50 + }); 51 + }; 52 + 53 + export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => { 54 + return (options?.client ?? _heyApiClient).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ 55 + url: '/api/v{api-version}/simple/$count', 56 + ...options 57 + }); 58 + }; 59 + 60 + export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => { 61 + return (options.client ?? _heyApiClient).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ 62 + url: '/api/v{api-version}/simple:operation', 63 + ...options 64 + }); 65 + }; 66 + 67 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => { 68 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 69 + url: '/api/v{api-version}/simple', 70 + ...options 71 + }); 72 + }; 73 + 74 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => { 75 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 76 + url: '/api/v{api-version}/simple', 77 + ...options 78 + }); 79 + }; 80 + 81 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => { 82 + return (options?.client ?? _heyApiClient).head<unknown, unknown, ThrowOnError>({ 83 + url: '/api/v{api-version}/simple', 84 + ...options 85 + }); 86 + }; 87 + 88 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => { 89 + return (options?.client ?? _heyApiClient).options<unknown, unknown, ThrowOnError>({ 90 + url: '/api/v{api-version}/simple', 91 + ...options 92 + }); 93 + }; 94 + 95 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => { 96 + return (options?.client ?? _heyApiClient).patch<unknown, unknown, ThrowOnError>({ 97 + url: '/api/v{api-version}/simple', 98 + ...options 99 + }); 100 + }; 101 + 102 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => { 103 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 104 + url: '/api/v{api-version}/simple', 105 + ...options 106 + }); 107 + }; 108 + 109 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => { 110 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 111 + url: '/api/v{api-version}/simple', 112 + ...options 113 + }); 114 + }; 115 + 116 + export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => { 117 + return (options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 118 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 119 + ...options 120 + }); 121 + }; 122 + 123 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 124 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 125 + url: '/api/v{api-version}/descriptions', 126 + ...options 127 + }); 128 + }; 129 + 130 + /** 131 + * @deprecated 132 + */ 133 + export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => { 134 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 135 + url: '/api/v{api-version}/parameters/deprecated', 136 + ...options 137 + }); 138 + }; 139 + 140 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => { 141 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 142 + url: '/api/v{api-version}/parameters/{parameterPath}', 143 + ...options, 144 + headers: { 145 + 'Content-Type': 'application/json', 146 + ...options.headers 147 + } 148 + }); 149 + }; 150 + 151 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 152 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 153 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 154 + ...options, 155 + headers: { 156 + 'Content-Type': 'application/json', 157 + ...options.headers 158 + } 159 + }); 160 + }; 161 + 162 + export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => { 163 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 164 + url: '/api/v{api-version}/parameters', 165 + ...options, 166 + headers: { 167 + 'Content-Type': 'application/json', 168 + ...options.headers 169 + } 170 + }); 171 + }; 172 + 173 + export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => { 174 + return (options.client ?? _heyApiClient).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 175 + url: '/api/v{api-version}/parameters', 176 + ...options, 177 + headers: { 178 + 'Content-Type': 'application/json', 179 + ...options.headers 180 + } 181 + }); 182 + }; 183 + 184 + export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => { 185 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 186 + url: '/api/v{api-version}/requestBody', 187 + ...options, 188 + headers: { 189 + 'Content-Type': 'application/json', 190 + ...options?.headers 191 + } 192 + }); 193 + }; 194 + 195 + export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => { 196 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 197 + ...formDataBodySerializer, 198 + url: '/api/v{api-version}/formData', 199 + ...options, 200 + headers: { 201 + 'Content-Type': null, 202 + ...options?.headers 203 + } 204 + }); 205 + }; 206 + 207 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => { 208 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 209 + url: '/api/v{api-version}/defaults', 210 + ...options 211 + }); 212 + }; 213 + 214 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => { 215 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 216 + url: '/api/v{api-version}/defaults', 217 + ...options 218 + }); 219 + }; 220 + 221 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => { 222 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 223 + url: '/api/v{api-version}/defaults', 224 + ...options 225 + }); 226 + }; 227 + 228 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => { 229 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 230 + url: '/api/v{api-version}/duplicate', 231 + ...options 232 + }); 233 + }; 234 + 235 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => { 236 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 237 + url: '/api/v{api-version}/duplicate', 238 + ...options 239 + }); 240 + }; 241 + 242 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => { 243 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 244 + url: '/api/v{api-version}/duplicate', 245 + ...options 246 + }); 247 + }; 248 + 249 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => { 250 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 251 + url: '/api/v{api-version}/duplicate', 252 + ...options 253 + }); 254 + }; 255 + 256 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => { 257 + return (options?.client ?? _heyApiClient).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ 258 + url: '/api/v{api-version}/no-content', 259 + ...options 260 + }); 261 + }; 262 + 263 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => { 264 + return (options?.client ?? _heyApiClient).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ 265 + url: '/api/v{api-version}/multiple-tags/response-and-no-content', 266 + ...options 267 + }); 268 + }; 269 + 270 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => { 271 + return (options?.client ?? _heyApiClient).get<DummyAResponses, unknown, ThrowOnError>({ 272 + url: '/api/v{api-version}/multiple-tags/a', 273 + ...options 274 + }); 275 + }; 276 + 277 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => { 278 + return (options?.client ?? _heyApiClient).get<DummyBResponses, unknown, ThrowOnError>({ 279 + url: '/api/v{api-version}/multiple-tags/b', 280 + ...options 281 + }); 282 + }; 283 + 284 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => { 285 + return (options?.client ?? _heyApiClient).get<CallWithResponseResponses, unknown, ThrowOnError>({ 286 + url: '/api/v{api-version}/response', 287 + ...options 288 + }); 289 + }; 290 + 291 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => { 292 + return (options?.client ?? _heyApiClient).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ 293 + url: '/api/v{api-version}/response', 294 + ...options 295 + }); 296 + }; 297 + 298 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => { 299 + return (options?.client ?? _heyApiClient).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ 300 + url: '/api/v{api-version}/response', 301 + ...options 302 + }); 303 + }; 304 + 305 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => { 306 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 307 + url: '/api/v{api-version}/collectionFormat', 308 + ...options 309 + }); 310 + }; 311 + 312 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 313 + return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 314 + url: '/api/v{api-version}/types', 315 + ...options 316 + }); 317 + }; 318 + 319 + export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => { 320 + return (options.client ?? _heyApiClient).post<UploadFileResponses, unknown, ThrowOnError>({ 321 + ...urlSearchParamsBodySerializer, 322 + url: '/api/v{api-version}/upload', 323 + ...options, 324 + headers: { 325 + 'Content-Type': 'application/x-www-form-urlencoded', 326 + ...options.headers 327 + } 328 + }); 329 + }; 330 + 331 + export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => { 332 + return (options.client ?? _heyApiClient).get<FileResponseResponses, unknown, ThrowOnError>({ 333 + url: '/api/v{api-version}/file/{id}', 334 + ...options 335 + }); 336 + }; 337 + 338 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => { 339 + return (options.client ?? _heyApiClient).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 340 + url: '/api/v{api-version}/complex', 341 + ...options 342 + }); 343 + }; 344 + 345 + export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => { 346 + return (options?.client ?? _heyApiClient).get<MultipartResponseResponses, unknown, ThrowOnError>({ 347 + url: '/api/v{api-version}/multipart', 348 + ...options 349 + }); 350 + }; 351 + 352 + export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => { 353 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 354 + ...formDataBodySerializer, 355 + url: '/api/v{api-version}/multipart', 356 + ...options, 357 + headers: { 358 + 'Content-Type': null, 359 + ...options?.headers 360 + } 361 + }); 362 + }; 363 + 364 + export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => { 365 + return (options.client ?? _heyApiClient).put<ComplexParamsResponses, unknown, ThrowOnError>({ 366 + url: '/api/v{api-version}/complex/{id}', 367 + ...options, 368 + headers: { 369 + 'Content-Type': 'application/json-patch+json', 370 + ...options.headers 371 + } 372 + }); 373 + }; 374 + 375 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => { 376 + return (options?.client ?? _heyApiClient).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ 377 + url: '/api/v{api-version}/header', 378 + ...options 379 + }); 380 + }; 381 + 382 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => { 383 + return (options.client ?? _heyApiClient).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ 384 + url: '/api/v{api-version}/error', 385 + ...options 386 + }); 387 + }; 388 + 389 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => { 390 + return (options.client ?? _heyApiClient).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ 391 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 392 + ...options 393 + }); 394 + }; 395 + 396 + /** 397 + * Login User 398 + */ 399 + export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => { 400 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 401 + ...urlSearchParamsBodySerializer, 402 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 403 + ...options, 404 + headers: { 405 + 'Content-Type': 'application/x-www-form-urlencoded', 406 + ...options.headers 407 + } 408 + }); 409 + };
+2063
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * External ref to shared model (A) 10 + */ 11 + export type ExternalRefA = { 12 + id: string; 13 + name?: string; 14 + }; 15 + 16 + /** 17 + * External ref to shared model (B) 18 + */ 19 + export type ExternalRefB = ExternalRefA; 20 + 21 + /** 22 + * Testing multiline comments in string: First line 23 + * Second line 24 + * 25 + * Fourth line 26 + */ 27 + export type CamelCaseCommentWithBreaks = number; 28 + 29 + /** 30 + * Testing multiline comments in string: First line 31 + * Second line 32 + * 33 + * Fourth line 34 + */ 35 + export type CommentWithBreaks = number; 36 + 37 + /** 38 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 39 + */ 40 + export type CommentWithBackticks = number; 41 + 42 + /** 43 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 44 + */ 45 + export type CommentWithBackticksAndQuotes = number; 46 + 47 + /** 48 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 49 + */ 50 + export type CommentWithSlashes = number; 51 + 52 + /** 53 + * Testing expression placeholders in string: ${expression} should work 54 + */ 55 + export type CommentWithExpressionPlaceholders = number; 56 + 57 + /** 58 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 59 + */ 60 + export type CommentWithQuotes = number; 61 + 62 + /** 63 + * Testing reserved characters in string: * inline * and ** inline ** should work 64 + */ 65 + export type CommentWithReservedCharacters = number; 66 + 67 + /** 68 + * This is a simple number 69 + */ 70 + export type SimpleInteger = number; 71 + 72 + /** 73 + * This is a simple boolean 74 + */ 75 + export type SimpleBoolean = boolean; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export type SimpleString = string; 81 + 82 + /** 83 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 84 + */ 85 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 86 + 87 + /** 88 + * This is a simple file 89 + */ 90 + export type SimpleFile = Blob | File; 91 + 92 + /** 93 + * This is a simple reference 94 + */ 95 + export type SimpleReference = ModelWithString; 96 + 97 + /** 98 + * This is a simple string 99 + */ 100 + export type SimpleStringWithPattern = string | null; 101 + 102 + /** 103 + * This is a simple enum with strings 104 + */ 105 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 106 + 107 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 108 + 109 + /** 110 + * This is a simple enum with numbers 111 + */ 112 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 113 + 114 + /** 115 + * Success=1,Warning=2,Error=3 116 + */ 117 + export type EnumFromDescription = number; 118 + 119 + /** 120 + * This is a simple enum with numbers 121 + */ 122 + export type EnumWithExtensions = 200 | 400 | 500; 123 + 124 + export type EnumWithXEnumNames = 0 | 1 | 2; 125 + 126 + /** 127 + * This is a simple array with numbers 128 + */ 129 + export type ArrayWithNumbers = Array<number>; 130 + 131 + /** 132 + * This is a simple array with booleans 133 + */ 134 + export type ArrayWithBooleans = Array<boolean>; 135 + 136 + /** 137 + * This is a simple array with strings 138 + */ 139 + export type ArrayWithStrings = Array<string>; 140 + 141 + /** 142 + * This is a simple array with references 143 + */ 144 + export type ArrayWithReferences = Array<ModelWithString>; 145 + 146 + /** 147 + * This is a simple array containing an array 148 + */ 149 + export type ArrayWithArray = Array<Array<ModelWithString>>; 150 + 151 + /** 152 + * This is a simple array with properties 153 + */ 154 + export type ArrayWithProperties = Array<{ 155 + '16x16'?: CamelCaseCommentWithBreaks; 156 + bar?: string; 157 + }>; 158 + 159 + /** 160 + * This is a simple array with any of properties 161 + */ 162 + export type ArrayWithAnyOfProperties = Array<{ 163 + foo?: string; 164 + } | { 165 + bar?: string; 166 + }>; 167 + 168 + export type AnyOfAnyAndNull = { 169 + data?: unknown | null; 170 + }; 171 + 172 + /** 173 + * This is a simple array with any of properties 174 + */ 175 + export type AnyOfArrays = { 176 + results?: Array<{ 177 + foo?: string; 178 + } | { 179 + bar?: string; 180 + }>; 181 + }; 182 + 183 + /** 184 + * This is a string dictionary 185 + */ 186 + export type DictionaryWithString = { 187 + [key: string]: string; 188 + }; 189 + 190 + export type DictionaryWithPropertiesAndAdditionalProperties = { 191 + foo?: number; 192 + bar?: boolean; 193 + [key: string]: string | number | boolean | undefined; 194 + }; 195 + 196 + /** 197 + * This is a string reference 198 + */ 199 + export type DictionaryWithReference = { 200 + [key: string]: ModelWithString; 201 + }; 202 + 203 + /** 204 + * This is a complex dictionary 205 + */ 206 + export type DictionaryWithArray = { 207 + [key: string]: Array<ModelWithString>; 208 + }; 209 + 210 + /** 211 + * This is a string dictionary 212 + */ 213 + export type DictionaryWithDictionary = { 214 + [key: string]: { 215 + [key: string]: string; 216 + }; 217 + }; 218 + 219 + /** 220 + * This is a complex dictionary 221 + */ 222 + export type DictionaryWithProperties = { 223 + [key: string]: { 224 + foo?: string; 225 + bar?: string; 226 + }; 227 + }; 228 + 229 + /** 230 + * This is a model with one number property 231 + */ 232 + export type ModelWithInteger = { 233 + /** 234 + * This is a simple number property 235 + */ 236 + prop?: number; 237 + }; 238 + 239 + /** 240 + * This is a model with one boolean property 241 + */ 242 + export type ModelWithBoolean = { 243 + /** 244 + * This is a simple boolean property 245 + */ 246 + prop?: boolean; 247 + }; 248 + 249 + /** 250 + * This is a model with one string property 251 + */ 252 + export type ModelWithString = { 253 + /** 254 + * This is a simple string property 255 + */ 256 + prop?: string; 257 + }; 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export type ModelWithStringError = { 263 + /** 264 + * This is a simple string property 265 + */ 266 + prop?: string; 267 + }; 268 + 269 + /** 270 + * `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) 271 + */ 272 + export type ModelFromZendesk = string; 273 + 274 + /** 275 + * This is a model with one string property 276 + */ 277 + export type ModelWithNullableString = { 278 + /** 279 + * This is a simple string property 280 + */ 281 + nullableProp1?: string | null; 282 + /** 283 + * This is a simple string property 284 + */ 285 + nullableRequiredProp1: string | null; 286 + /** 287 + * This is a simple string property 288 + */ 289 + nullableProp2?: string | null; 290 + /** 291 + * This is a simple string property 292 + */ 293 + nullableRequiredProp2: string | null; 294 + /** 295 + * This is a simple enum with strings 296 + */ 297 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 298 + }; 299 + 300 + /** 301 + * This is a model with one enum 302 + */ 303 + export type ModelWithEnum = { 304 + /** 305 + * This is a simple enum with strings 306 + */ 307 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 308 + /** 309 + * These are the HTTP error code enums 310 + */ 311 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 312 + /** 313 + * Simple boolean enum 314 + */ 315 + bool?: true; 316 + }; 317 + 318 + /** 319 + * This is a model with one enum with escaped name 320 + */ 321 + export type ModelWithEnumWithHyphen = { 322 + /** 323 + * Foo-Bar-Baz-Qux 324 + */ 325 + 'foo-bar-baz-qux'?: '3.0'; 326 + }; 327 + 328 + /** 329 + * This is a model with one enum 330 + */ 331 + export type ModelWithEnumFromDescription = { 332 + /** 333 + * Success=1,Warning=2,Error=3 334 + */ 335 + test?: number; 336 + }; 337 + 338 + /** 339 + * This is a model with nested enums 340 + */ 341 + export type ModelWithNestedEnums = { 342 + dictionaryWithEnum?: { 343 + [key: string]: 'Success' | 'Warning' | 'Error'; 344 + }; 345 + dictionaryWithEnumFromDescription?: { 346 + [key: string]: number; 347 + }; 348 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 349 + arrayWithDescription?: Array<number>; 350 + /** 351 + * This is a simple enum with strings 352 + */ 353 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 354 + }; 355 + 356 + /** 357 + * This is a model with one property containing a reference 358 + */ 359 + export type ModelWithReference = { 360 + prop?: ModelWithProperties; 361 + }; 362 + 363 + /** 364 + * This is a model with one property containing an array 365 + */ 366 + export type ModelWithArrayReadOnlyAndWriteOnly = { 367 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 368 + propWithFile?: Array<Blob | File>; 369 + propWithNumber?: Array<number>; 370 + }; 371 + 372 + /** 373 + * This is a model with one property containing an array 374 + */ 375 + export type ModelWithArray = { 376 + prop?: Array<ModelWithString>; 377 + propWithFile?: Array<Blob | File>; 378 + propWithNumber?: Array<number>; 379 + }; 380 + 381 + /** 382 + * This is a model with one property containing a dictionary 383 + */ 384 + export type ModelWithDictionary = { 385 + prop?: { 386 + [key: string]: string; 387 + }; 388 + }; 389 + 390 + /** 391 + * This is a deprecated model with a deprecated property 392 + * @deprecated 393 + */ 394 + export type DeprecatedModel = { 395 + /** 396 + * This is a deprecated property 397 + * @deprecated 398 + */ 399 + prop?: string; 400 + }; 401 + 402 + /** 403 + * This is a model with one property containing a circular reference 404 + */ 405 + export type ModelWithCircularReference = { 406 + prop?: ModelWithCircularReference; 407 + }; 408 + 409 + /** 410 + * This is a model with one property with a 'one of' relationship 411 + */ 412 + export type CompositionWithOneOf = { 413 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 414 + }; 415 + 416 + /** 417 + * This is a model with one property with a 'one of' relationship where the options are not $ref 418 + */ 419 + export type CompositionWithOneOfAnonymous = { 420 + propA?: { 421 + propA?: string; 422 + } | string | number; 423 + }; 424 + 425 + /** 426 + * Circle 427 + */ 428 + export type ModelCircle = { 429 + kind: string; 430 + radius?: number; 431 + }; 432 + 433 + /** 434 + * Square 435 + */ 436 + export type ModelSquare = { 437 + kind: string; 438 + sideLength?: number; 439 + }; 440 + 441 + /** 442 + * This is a model with one property with a 'one of' relationship where the options are not $ref 443 + */ 444 + export type CompositionWithOneOfDiscriminator = ({ 445 + kind: 'circle'; 446 + } & ModelCircle) | ({ 447 + kind: 'square'; 448 + } & ModelSquare); 449 + 450 + /** 451 + * This is a model with one property with a 'any of' relationship 452 + */ 453 + export type CompositionWithAnyOf = { 454 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 455 + }; 456 + 457 + /** 458 + * This is a model with one property with a 'any of' relationship where the options are not $ref 459 + */ 460 + export type CompositionWithAnyOfAnonymous = { 461 + propA?: { 462 + propA?: string; 463 + } | string | number; 464 + }; 465 + 466 + /** 467 + * This is a model with nested 'any of' property with a type null 468 + */ 469 + export type CompositionWithNestedAnyAndTypeNull = { 470 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 471 + }; 472 + 473 + export type _3eNum1Период = 'Bird' | 'Dog'; 474 + 475 + export type ConstValue = 'ConstValue'; 476 + 477 + /** 478 + * This is a model with one property with a 'any of' relationship where the options are not $ref 479 + */ 480 + export type CompositionWithNestedAnyOfAndNull = { 481 + /** 482 + * Scopes 483 + */ 484 + propA?: Array<_3eNum1Период | ConstValue> | null; 485 + }; 486 + 487 + /** 488 + * This is a model with one property with a 'one of' relationship 489 + */ 490 + export type CompositionWithOneOfAndNullable = { 491 + propA?: { 492 + boolean?: boolean; 493 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 494 + }; 495 + 496 + /** 497 + * This is a model that contains a simple dictionary within composition 498 + */ 499 + export type CompositionWithOneOfAndSimpleDictionary = { 500 + propA?: boolean | { 501 + [key: string]: number; 502 + }; 503 + }; 504 + 505 + /** 506 + * This is a model that contains a dictionary of simple arrays within composition 507 + */ 508 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 509 + propA?: boolean | { 510 + [key: string]: Array<boolean>; 511 + }; 512 + }; 513 + 514 + /** 515 + * This is a model that contains a dictionary of complex arrays (composited) within composition 516 + */ 517 + export type CompositionWithOneOfAndComplexArrayDictionary = { 518 + propA?: boolean | { 519 + [key: string]: Array<number | string>; 520 + }; 521 + }; 522 + 523 + /** 524 + * This is a model with one property with a 'all of' relationship 525 + */ 526 + export type CompositionWithAllOfAndNullable = { 527 + propA?: ({ 528 + boolean?: boolean; 529 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 530 + }; 531 + 532 + /** 533 + * This is a model with one property with a 'any of' relationship 534 + */ 535 + export type CompositionWithAnyOfAndNullable = { 536 + propA?: { 537 + boolean?: boolean; 538 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 539 + }; 540 + 541 + /** 542 + * This is a base model with two simple optional properties 543 + */ 544 + export type CompositionBaseModel = { 545 + firstName?: string; 546 + lastname?: string; 547 + }; 548 + 549 + /** 550 + * This is a model that extends the base model 551 + */ 552 + export type CompositionExtendedModel = CompositionBaseModel & { 553 + age: number; 554 + firstName: string; 555 + lastname: string; 556 + }; 557 + 558 + /** 559 + * This is a model with one nested property 560 + */ 561 + export type ModelWithProperties = { 562 + required: string; 563 + readonly requiredAndReadOnly: string; 564 + requiredAndNullable: string | null; 565 + string?: string; 566 + number?: number; 567 + boolean?: boolean; 568 + reference?: ModelWithString; 569 + 'property with space'?: string; 570 + default?: string; 571 + try?: string; 572 + readonly '@namespace.string'?: string; 573 + readonly '@namespace.integer'?: number; 574 + }; 575 + 576 + /** 577 + * This is a model with one nested property 578 + */ 579 + export type ModelWithNestedProperties = { 580 + readonly first: { 581 + readonly second: { 582 + readonly third: string | null; 583 + } | null; 584 + } | null; 585 + }; 586 + 587 + /** 588 + * This is a model with duplicated properties 589 + */ 590 + export type ModelWithDuplicateProperties = { 591 + prop?: ModelWithString; 592 + }; 593 + 594 + /** 595 + * This is a model with ordered properties 596 + */ 597 + export type ModelWithOrderedProperties = { 598 + zebra?: string; 599 + apple?: string; 600 + hawaii?: string; 601 + }; 602 + 603 + /** 604 + * This is a model with duplicated imports 605 + */ 606 + export type ModelWithDuplicateImports = { 607 + propA?: ModelWithString; 608 + propB?: ModelWithString; 609 + propC?: ModelWithString; 610 + }; 611 + 612 + /** 613 + * This is a model that extends another model 614 + */ 615 + export type ModelThatExtends = ModelWithString & { 616 + propExtendsA?: string; 617 + propExtendsB?: ModelWithString; 618 + }; 619 + 620 + /** 621 + * This is a model that extends another model 622 + */ 623 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 624 + propExtendsC?: string; 625 + propExtendsD?: ModelWithString; 626 + }; 627 + 628 + /** 629 + * This is a model that contains a some patterns 630 + */ 631 + export type ModelWithPattern = { 632 + key: string; 633 + name: string; 634 + readonly enabled?: boolean; 635 + readonly modified?: string; 636 + id?: string; 637 + text?: string; 638 + patternWithSingleQuotes?: string; 639 + patternWithNewline?: string; 640 + patternWithBacktick?: string; 641 + }; 642 + 643 + export type File = { 644 + /** 645 + * Id 646 + */ 647 + readonly id?: string; 648 + /** 649 + * Updated at 650 + */ 651 + readonly updated_at?: string; 652 + /** 653 + * Created at 654 + */ 655 + readonly created_at?: string; 656 + /** 657 + * Mime 658 + */ 659 + mime: string; 660 + /** 661 + * File 662 + */ 663 + readonly file?: string; 664 + }; 665 + 666 + export type Default = { 667 + name?: string; 668 + }; 669 + 670 + export type Pageable = { 671 + page?: number; 672 + size?: number; 673 + sort?: Array<string>; 674 + }; 675 + 676 + /** 677 + * This is a free-form object without additionalProperties. 678 + */ 679 + export type FreeFormObjectWithoutAdditionalProperties = { 680 + [key: string]: unknown; 681 + }; 682 + 683 + /** 684 + * This is a free-form object with additionalProperties: true. 685 + */ 686 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 687 + [key: string]: unknown; 688 + }; 689 + 690 + /** 691 + * This is a free-form object with additionalProperties: {}. 692 + */ 693 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 694 + [key: string]: unknown; 695 + }; 696 + 697 + export type ModelWithConst = { 698 + String?: 'String'; 699 + number?: 0; 700 + null?: null; 701 + withType?: 'Some string'; 702 + }; 703 + 704 + /** 705 + * This is a model with one property and additionalProperties: true 706 + */ 707 + export type ModelWithAdditionalPropertiesEqTrue = { 708 + /** 709 + * This is a simple string property 710 + */ 711 + prop?: string; 712 + [key: string]: unknown | string | undefined; 713 + }; 714 + 715 + export type NestedAnyOfArraysNullable = { 716 + nullableArray?: Array<string | boolean> | null; 717 + }; 718 + 719 + export type CompositionWithOneOfAndProperties = ({ 720 + foo: SimpleParameter; 721 + } | { 722 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 723 + }) & { 724 + baz: number | null; 725 + qux: number; 726 + }; 727 + 728 + /** 729 + * An object that can be null 730 + */ 731 + export type NullableObject = { 732 + foo?: string; 733 + } | null; 734 + 735 + /** 736 + * Some % character 737 + */ 738 + export type CharactersInDescription = string; 739 + 740 + export type ModelWithNullableObject = { 741 + data?: NullableObject; 742 + }; 743 + 744 + export type ModelWithOneOfEnum = { 745 + foo: 'Bar'; 746 + } | { 747 + foo: 'Baz'; 748 + } | { 749 + foo: 'Qux'; 750 + } | { 751 + content: string; 752 + foo: 'Quux'; 753 + } | { 754 + content: [ 755 + string, 756 + string 757 + ]; 758 + foo: 'Corge'; 759 + }; 760 + 761 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 762 + 763 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 764 + 765 + export type ModelWithNestedArrayEnumsData = { 766 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 767 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 768 + }; 769 + 770 + export type ModelWithNestedArrayEnums = { 771 + array_strings?: Array<string>; 772 + data?: ModelWithNestedArrayEnumsData; 773 + }; 774 + 775 + export type ModelWithNestedCompositionEnums = { 776 + foo?: ModelWithNestedArrayEnumsDataFoo; 777 + }; 778 + 779 + export type ModelWithReadOnlyAndWriteOnly = { 780 + foo: string; 781 + readonly bar: string; 782 + }; 783 + 784 + export type ModelWithConstantSizeArray = [ 785 + number, 786 + number 787 + ]; 788 + 789 + export type ModelWithAnyOfConstantSizeArray = [ 790 + number | string, 791 + number | string, 792 + number | string 793 + ]; 794 + 795 + export type ModelWithPrefixItemsConstantSizeArray = [ 796 + ModelWithInteger, 797 + number | string, 798 + string 799 + ]; 800 + 801 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 802 + number | null | string, 803 + number | null | string, 804 + number | null | string 805 + ]; 806 + 807 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 808 + number | Import, 809 + number | Import 810 + ]; 811 + 812 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 813 + number & string, 814 + number & string 815 + ]; 816 + 817 + export type ModelWithNumericEnumUnion = { 818 + /** 819 + * Период 820 + */ 821 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 822 + }; 823 + 824 + /** 825 + * Some description with `back ticks` 826 + */ 827 + export type ModelWithBackticksInDescription = { 828 + /** 829 + * The template `that` should be used for parsing and importing the contents of the CSV file. 830 + * 831 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 832 + * <pre> 833 + * [ 834 + * { 835 + * "resourceType": "Asset", 836 + * "identifier": { 837 + * "name": "${1}", 838 + * "domain": { 839 + * "name": "${2}", 840 + * "community": { 841 + * "name": "Some Community" 842 + * } 843 + * } 844 + * }, 845 + * "attributes" : { 846 + * "00000000-0000-0000-0000-000000003115" : [ { 847 + * "value" : "${3}" 848 + * } ], 849 + * "00000000-0000-0000-0000-000000000222" : [ { 850 + * "value" : "${4}" 851 + * } ] 852 + * } 853 + * } 854 + * ] 855 + * </pre> 856 + */ 857 + template?: string; 858 + }; 859 + 860 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 861 + baz: number | null; 862 + qux: number; 863 + }; 864 + 865 + /** 866 + * Model used to test deduplication strategy (unused) 867 + */ 868 + export type ParameterSimpleParameterUnused = string; 869 + 870 + /** 871 + * Model used to test deduplication strategy 872 + */ 873 + export type PostServiceWithEmptyTagResponse = string; 874 + 875 + /** 876 + * Model used to test deduplication strategy 877 + */ 878 + export type PostServiceWithEmptyTagResponse2 = string; 879 + 880 + /** 881 + * Model used to test deduplication strategy 882 + */ 883 + export type DeleteFooData = string; 884 + 885 + /** 886 + * Model used to test deduplication strategy 887 + */ 888 + export type DeleteFooData2 = string; 889 + 890 + /** 891 + * Model with restricted keyword name 892 + */ 893 + export type Import = string; 894 + 895 + export type SchemaWithFormRestrictedKeys = { 896 + description?: string; 897 + 'x-enum-descriptions'?: string; 898 + 'x-enum-varnames'?: string; 899 + 'x-enumNames'?: string; 900 + title?: string; 901 + object?: { 902 + description?: string; 903 + 'x-enum-descriptions'?: string; 904 + 'x-enum-varnames'?: string; 905 + 'x-enumNames'?: string; 906 + title?: string; 907 + }; 908 + array?: Array<{ 909 + description?: string; 910 + 'x-enum-descriptions'?: string; 911 + 'x-enum-varnames'?: string; 912 + 'x-enumNames'?: string; 913 + title?: string; 914 + }>; 915 + }; 916 + 917 + /** 918 + * This schema was giving PascalCase transformations a hard time 919 + */ 920 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 921 + /** 922 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 923 + */ 924 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 925 + }; 926 + 927 + /** 928 + * This schema was giving PascalCase transformations a hard time 929 + */ 930 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 931 + /** 932 + * Specifies the target ResourceVersion 933 + */ 934 + resourceVersion?: string; 935 + /** 936 + * Specifies the target UID. 937 + */ 938 + uid?: string; 939 + }; 940 + 941 + export type AdditionalPropertiesUnknownIssue = { 942 + [key: string]: string | number; 943 + }; 944 + 945 + export type AdditionalPropertiesUnknownIssue2 = { 946 + [key: string]: string | number; 947 + }; 948 + 949 + export type AdditionalPropertiesUnknownIssue3 = string & { 950 + entries: { 951 + [key: string]: AdditionalPropertiesUnknownIssue; 952 + }; 953 + }; 954 + 955 + export type AdditionalPropertiesIntegerIssue = { 956 + value: number; 957 + [key: string]: number; 958 + }; 959 + 960 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 961 + 962 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 963 + item?: boolean; 964 + error?: string | null; 965 + readonly hasError?: boolean; 966 + data?: { 967 + [key: string]: never; 968 + }; 969 + }; 970 + 971 + export type GenericSchemaDuplicateIssue1SystemString = { 972 + item?: string | null; 973 + error?: string | null; 974 + readonly hasError?: boolean; 975 + }; 976 + 977 + /** 978 + * This is a model with one nested property 979 + */ 980 + export type ModelWithPropertiesWritable = { 981 + required: string; 982 + requiredAndNullable: string | null; 983 + string?: string; 984 + number?: number; 985 + boolean?: boolean; 986 + reference?: ModelWithString; 987 + 'property with space'?: string; 988 + default?: string; 989 + try?: string; 990 + }; 991 + 992 + /** 993 + * This is a model that contains a some patterns 994 + */ 995 + export type ModelWithPatternWritable = { 996 + key: string; 997 + name: string; 998 + id?: string; 999 + text?: string; 1000 + patternWithSingleQuotes?: string; 1001 + patternWithNewline?: string; 1002 + patternWithBacktick?: string; 1003 + }; 1004 + 1005 + export type FileWritable = { 1006 + /** 1007 + * Mime 1008 + */ 1009 + mime: string; 1010 + }; 1011 + 1012 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1013 + foo: string; 1014 + baz: string; 1015 + }; 1016 + 1017 + export type AdditionalPropertiesUnknownIssueWritable = { 1018 + [key: string]: string | number; 1019 + }; 1020 + 1021 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1022 + item?: boolean; 1023 + error?: string | null; 1024 + data?: { 1025 + [key: string]: never; 1026 + }; 1027 + }; 1028 + 1029 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1030 + item?: string | null; 1031 + error?: string | null; 1032 + }; 1033 + 1034 + /** 1035 + * This is a reusable parameter 1036 + */ 1037 + export type SimpleParameter = string; 1038 + 1039 + /** 1040 + * Parameter with illegal characters 1041 + */ 1042 + export type XFooBar = ModelWithString; 1043 + 1044 + /** 1045 + * A reusable request body 1046 + */ 1047 + export type SimpleRequestBody = ModelWithString; 1048 + 1049 + /** 1050 + * A reusable request body 1051 + */ 1052 + export type SimpleFormData = ModelWithString; 1053 + 1054 + export type ExportData = { 1055 + body?: never; 1056 + path?: never; 1057 + query?: never; 1058 + url: '/api/v{api-version}/no+tag'; 1059 + }; 1060 + 1061 + export type PatchApiVbyApiVersionNoTagData = { 1062 + body?: never; 1063 + path?: never; 1064 + query?: never; 1065 + url: '/api/v{api-version}/no+tag'; 1066 + }; 1067 + 1068 + export type PatchApiVbyApiVersionNoTagResponses = { 1069 + /** 1070 + * OK 1071 + */ 1072 + default: unknown; 1073 + }; 1074 + 1075 + export type ImportData = { 1076 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; 1077 + path?: never; 1078 + query?: never; 1079 + url: '/api/v{api-version}/no+tag'; 1080 + }; 1081 + 1082 + export type ImportResponses = { 1083 + /** 1084 + * Success 1085 + */ 1086 + 200: ModelFromZendesk; 1087 + /** 1088 + * Default success response 1089 + */ 1090 + default: ModelWithReadOnlyAndWriteOnly; 1091 + }; 1092 + 1093 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1094 + 1095 + export type FooWowData = { 1096 + body?: never; 1097 + path?: never; 1098 + query?: never; 1099 + url: '/api/v{api-version}/no+tag'; 1100 + }; 1101 + 1102 + export type FooWowResponses = { 1103 + /** 1104 + * OK 1105 + */ 1106 + default: unknown; 1107 + }; 1108 + 1109 + export type ApiVVersionODataControllerCountData = { 1110 + body?: never; 1111 + path?: never; 1112 + query?: never; 1113 + url: '/api/v{api-version}/simple/$count'; 1114 + }; 1115 + 1116 + export type ApiVVersionODataControllerCountResponses = { 1117 + /** 1118 + * Success 1119 + */ 1120 + 200: ModelFromZendesk; 1121 + }; 1122 + 1123 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1124 + 1125 + export type GetApiVbyApiVersionSimpleOperationData = { 1126 + body?: never; 1127 + path: { 1128 + /** 1129 + * foo in method 1130 + */ 1131 + foo_param: string; 1132 + }; 1133 + query?: never; 1134 + url: '/api/v{api-version}/simple:operation'; 1135 + }; 1136 + 1137 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1138 + /** 1139 + * Default error response 1140 + */ 1141 + default: ModelWithBoolean; 1142 + }; 1143 + 1144 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1145 + 1146 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1147 + /** 1148 + * Response is a simple number 1149 + */ 1150 + 200: number; 1151 + }; 1152 + 1153 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1154 + 1155 + export type DeleteCallWithoutParametersAndResponseData = { 1156 + body?: never; 1157 + path?: never; 1158 + query?: never; 1159 + url: '/api/v{api-version}/simple'; 1160 + }; 1161 + 1162 + export type GetCallWithoutParametersAndResponseData = { 1163 + body?: never; 1164 + path?: never; 1165 + query?: never; 1166 + url: '/api/v{api-version}/simple'; 1167 + }; 1168 + 1169 + export type HeadCallWithoutParametersAndResponseData = { 1170 + body?: never; 1171 + path?: never; 1172 + query?: never; 1173 + url: '/api/v{api-version}/simple'; 1174 + }; 1175 + 1176 + export type OptionsCallWithoutParametersAndResponseData = { 1177 + body?: never; 1178 + path?: never; 1179 + query?: never; 1180 + url: '/api/v{api-version}/simple'; 1181 + }; 1182 + 1183 + export type PatchCallWithoutParametersAndResponseData = { 1184 + body?: never; 1185 + path?: never; 1186 + query?: never; 1187 + url: '/api/v{api-version}/simple'; 1188 + }; 1189 + 1190 + export type PostCallWithoutParametersAndResponseData = { 1191 + body?: never; 1192 + path?: never; 1193 + query?: never; 1194 + url: '/api/v{api-version}/simple'; 1195 + }; 1196 + 1197 + export type PutCallWithoutParametersAndResponseData = { 1198 + body?: never; 1199 + path?: never; 1200 + query?: never; 1201 + url: '/api/v{api-version}/simple'; 1202 + }; 1203 + 1204 + export type DeleteFooData3 = { 1205 + body?: never; 1206 + headers: { 1207 + /** 1208 + * Parameter with illegal characters 1209 + */ 1210 + 'x-Foo-Bar': ModelWithString; 1211 + }; 1212 + path: { 1213 + /** 1214 + * foo in method 1215 + */ 1216 + foo_param: string; 1217 + /** 1218 + * bar in method 1219 + */ 1220 + BarParam: string; 1221 + }; 1222 + query?: never; 1223 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1224 + }; 1225 + 1226 + export type CallWithDescriptionsData = { 1227 + body?: never; 1228 + path?: never; 1229 + query?: { 1230 + /** 1231 + * Testing multiline comments in string: First line 1232 + * Second line 1233 + * 1234 + * Fourth line 1235 + */ 1236 + parameterWithBreaks?: string; 1237 + /** 1238 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1239 + */ 1240 + parameterWithBackticks?: string; 1241 + /** 1242 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1243 + */ 1244 + parameterWithSlashes?: string; 1245 + /** 1246 + * Testing expression placeholders in string: ${expression} should work 1247 + */ 1248 + parameterWithExpressionPlaceholders?: string; 1249 + /** 1250 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1251 + */ 1252 + parameterWithQuotes?: string; 1253 + /** 1254 + * Testing reserved characters in string: * inline * and ** inline ** should work 1255 + */ 1256 + parameterWithReservedCharacters?: string; 1257 + }; 1258 + url: '/api/v{api-version}/descriptions'; 1259 + }; 1260 + 1261 + export type DeprecatedCallData = { 1262 + body?: never; 1263 + headers: { 1264 + /** 1265 + * This parameter is deprecated 1266 + * @deprecated 1267 + */ 1268 + parameter: DeprecatedModel | null; 1269 + }; 1270 + path?: never; 1271 + query?: never; 1272 + url: '/api/v{api-version}/parameters/deprecated'; 1273 + }; 1274 + 1275 + export type CallWithParametersData = { 1276 + /** 1277 + * This is the parameter that goes into the body 1278 + */ 1279 + body: { 1280 + [key: string]: unknown; 1281 + } | null; 1282 + headers: { 1283 + /** 1284 + * This is the parameter that goes into the header 1285 + */ 1286 + parameterHeader: string | null; 1287 + }; 1288 + path: { 1289 + /** 1290 + * This is the parameter that goes into the path 1291 + */ 1292 + parameterPath: string | null; 1293 + /** 1294 + * api-version should be required in standalone clients 1295 + */ 1296 + 'api-version': string | null; 1297 + }; 1298 + query: { 1299 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1300 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1301 + /** 1302 + * This is the parameter that goes into the query params 1303 + */ 1304 + cursor: string | null; 1305 + }; 1306 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1307 + }; 1308 + 1309 + export type CallWithWeirdParameterNamesData = { 1310 + /** 1311 + * This is the parameter that goes into the body 1312 + */ 1313 + body: ModelWithString | null; 1314 + headers: { 1315 + /** 1316 + * This is the parameter that goes into the request header 1317 + */ 1318 + 'parameter.header': string | null; 1319 + }; 1320 + path: { 1321 + /** 1322 + * This is the parameter that goes into the path 1323 + */ 1324 + 'parameter.path.1'?: string; 1325 + /** 1326 + * This is the parameter that goes into the path 1327 + */ 1328 + 'parameter-path-2'?: string; 1329 + /** 1330 + * This is the parameter that goes into the path 1331 + */ 1332 + 'PARAMETER-PATH-3'?: string; 1333 + /** 1334 + * api-version should be required in standalone clients 1335 + */ 1336 + 'api-version': string | null; 1337 + }; 1338 + query: { 1339 + /** 1340 + * This is the parameter with a reserved keyword 1341 + */ 1342 + default?: string; 1343 + /** 1344 + * This is the parameter that goes into the request query params 1345 + */ 1346 + 'parameter-query': string | null; 1347 + }; 1348 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1349 + }; 1350 + 1351 + export type GetCallWithOptionalParamData = { 1352 + /** 1353 + * This is a required parameter 1354 + */ 1355 + body: ModelWithOneOfEnum; 1356 + path?: never; 1357 + query?: { 1358 + /** 1359 + * This is an optional parameter 1360 + */ 1361 + page?: number; 1362 + }; 1363 + url: '/api/v{api-version}/parameters'; 1364 + }; 1365 + 1366 + export type PostCallWithOptionalParamData = { 1367 + /** 1368 + * This is an optional parameter 1369 + */ 1370 + body?: { 1371 + offset?: number | null; 1372 + }; 1373 + path?: never; 1374 + query: { 1375 + /** 1376 + * This is a required parameter 1377 + */ 1378 + parameter: Pageable; 1379 + }; 1380 + url: '/api/v{api-version}/parameters'; 1381 + }; 1382 + 1383 + export type PostCallWithOptionalParamResponses = { 1384 + /** 1385 + * Response is a simple number 1386 + */ 1387 + 200: number; 1388 + /** 1389 + * Success 1390 + */ 1391 + 204: void; 1392 + }; 1393 + 1394 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1395 + 1396 + export type PostApiVbyApiVersionRequestBodyData = { 1397 + /** 1398 + * A reusable request body 1399 + */ 1400 + body?: SimpleRequestBody; 1401 + path?: never; 1402 + query?: { 1403 + /** 1404 + * This is a reusable parameter 1405 + */ 1406 + parameter?: string; 1407 + }; 1408 + url: '/api/v{api-version}/requestBody'; 1409 + }; 1410 + 1411 + export type PostApiVbyApiVersionFormDataData = { 1412 + /** 1413 + * A reusable request body 1414 + */ 1415 + body?: SimpleFormData; 1416 + path?: never; 1417 + query?: { 1418 + /** 1419 + * This is a reusable parameter 1420 + */ 1421 + parameter?: string; 1422 + }; 1423 + url: '/api/v{api-version}/formData'; 1424 + }; 1425 + 1426 + export type CallWithDefaultParametersData = { 1427 + body?: never; 1428 + path?: never; 1429 + query?: { 1430 + /** 1431 + * This is a simple string with default value 1432 + */ 1433 + parameterString?: string | null; 1434 + /** 1435 + * This is a simple number with default value 1436 + */ 1437 + parameterNumber?: number | null; 1438 + /** 1439 + * This is a simple boolean with default value 1440 + */ 1441 + parameterBoolean?: boolean | null; 1442 + /** 1443 + * This is a simple enum with default value 1444 + */ 1445 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1446 + /** 1447 + * This is a simple model with default value 1448 + */ 1449 + parameterModel?: ModelWithString | null; 1450 + }; 1451 + url: '/api/v{api-version}/defaults'; 1452 + }; 1453 + 1454 + export type CallWithDefaultOptionalParametersData = { 1455 + body?: never; 1456 + path?: never; 1457 + query?: { 1458 + /** 1459 + * This is a simple string that is optional with default value 1460 + */ 1461 + parameterString?: string; 1462 + /** 1463 + * This is a simple number that is optional with default value 1464 + */ 1465 + parameterNumber?: number; 1466 + /** 1467 + * This is a simple boolean that is optional with default value 1468 + */ 1469 + parameterBoolean?: boolean; 1470 + /** 1471 + * This is a simple enum that is optional with default value 1472 + */ 1473 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1474 + /** 1475 + * This is a simple model that is optional with default value 1476 + */ 1477 + parameterModel?: ModelWithString; 1478 + }; 1479 + url: '/api/v{api-version}/defaults'; 1480 + }; 1481 + 1482 + export type CallToTestOrderOfParamsData = { 1483 + body?: never; 1484 + path?: never; 1485 + query: { 1486 + /** 1487 + * This is a optional string with default 1488 + */ 1489 + parameterOptionalStringWithDefault?: string; 1490 + /** 1491 + * This is a optional string with empty default 1492 + */ 1493 + parameterOptionalStringWithEmptyDefault?: string; 1494 + /** 1495 + * This is a optional string with no default 1496 + */ 1497 + parameterOptionalStringWithNoDefault?: string; 1498 + /** 1499 + * This is a string with default 1500 + */ 1501 + parameterStringWithDefault: string; 1502 + /** 1503 + * This is a string with empty default 1504 + */ 1505 + parameterStringWithEmptyDefault: string; 1506 + /** 1507 + * This is a string with no default 1508 + */ 1509 + parameterStringWithNoDefault: string; 1510 + /** 1511 + * This is a string that can be null with no default 1512 + */ 1513 + parameterStringNullableWithNoDefault?: string | null; 1514 + /** 1515 + * This is a string that can be null with default 1516 + */ 1517 + parameterStringNullableWithDefault?: string | null; 1518 + }; 1519 + url: '/api/v{api-version}/defaults'; 1520 + }; 1521 + 1522 + export type DuplicateNameData = { 1523 + body?: never; 1524 + path?: never; 1525 + query?: never; 1526 + url: '/api/v{api-version}/duplicate'; 1527 + }; 1528 + 1529 + export type DuplicateName2Data = { 1530 + body?: never; 1531 + path?: never; 1532 + query?: never; 1533 + url: '/api/v{api-version}/duplicate'; 1534 + }; 1535 + 1536 + export type DuplicateName3Data = { 1537 + body?: never; 1538 + path?: never; 1539 + query?: never; 1540 + url: '/api/v{api-version}/duplicate'; 1541 + }; 1542 + 1543 + export type DuplicateName4Data = { 1544 + body?: never; 1545 + path?: never; 1546 + query?: never; 1547 + url: '/api/v{api-version}/duplicate'; 1548 + }; 1549 + 1550 + export type CallWithNoContentResponseData = { 1551 + body?: never; 1552 + path?: never; 1553 + query?: never; 1554 + url: '/api/v{api-version}/no-content'; 1555 + }; 1556 + 1557 + export type CallWithNoContentResponseResponses = { 1558 + /** 1559 + * Success 1560 + */ 1561 + 204: void; 1562 + }; 1563 + 1564 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1565 + 1566 + export type CallWithResponseAndNoContentResponseData = { 1567 + body?: never; 1568 + path?: never; 1569 + query?: never; 1570 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1571 + }; 1572 + 1573 + export type CallWithResponseAndNoContentResponseResponses = { 1574 + /** 1575 + * Response is a simple number 1576 + */ 1577 + 200: number; 1578 + /** 1579 + * Success 1580 + */ 1581 + 204: void; 1582 + }; 1583 + 1584 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1585 + 1586 + export type DummyAData = { 1587 + body?: never; 1588 + path?: never; 1589 + query?: never; 1590 + url: '/api/v{api-version}/multiple-tags/a'; 1591 + }; 1592 + 1593 + export type DummyAResponses = { 1594 + 200: _400; 1595 + }; 1596 + 1597 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1598 + 1599 + export type DummyBData = { 1600 + body?: never; 1601 + path?: never; 1602 + query?: never; 1603 + url: '/api/v{api-version}/multiple-tags/b'; 1604 + }; 1605 + 1606 + export type DummyBResponses = { 1607 + /** 1608 + * Success 1609 + */ 1610 + 204: void; 1611 + }; 1612 + 1613 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1614 + 1615 + export type CallWithResponseData = { 1616 + body?: never; 1617 + path?: never; 1618 + query?: never; 1619 + url: '/api/v{api-version}/response'; 1620 + }; 1621 + 1622 + export type CallWithResponseResponses = { 1623 + default: Import; 1624 + }; 1625 + 1626 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1627 + 1628 + export type CallWithDuplicateResponsesData = { 1629 + body?: never; 1630 + path?: never; 1631 + query?: never; 1632 + url: '/api/v{api-version}/response'; 1633 + }; 1634 + 1635 + export type CallWithDuplicateResponsesErrors = { 1636 + /** 1637 + * Message for 500 error 1638 + */ 1639 + 500: ModelWithStringError; 1640 + /** 1641 + * Message for 501 error 1642 + */ 1643 + 501: ModelWithStringError; 1644 + /** 1645 + * Message for 502 error 1646 + */ 1647 + 502: ModelWithStringError; 1648 + /** 1649 + * Message for 4XX errors 1650 + */ 1651 + '4XX': DictionaryWithArray; 1652 + /** 1653 + * Default error response 1654 + */ 1655 + default: ModelWithBoolean; 1656 + }; 1657 + 1658 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1659 + 1660 + export type CallWithDuplicateResponsesResponses = { 1661 + /** 1662 + * Message for 200 response 1663 + */ 1664 + 200: ModelWithBoolean & ModelWithInteger; 1665 + /** 1666 + * Message for 201 response 1667 + */ 1668 + 201: ModelWithString; 1669 + /** 1670 + * Message for 202 response 1671 + */ 1672 + 202: ModelWithString; 1673 + }; 1674 + 1675 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1676 + 1677 + export type CallWithResponsesData = { 1678 + body?: never; 1679 + path?: never; 1680 + query?: never; 1681 + url: '/api/v{api-version}/response'; 1682 + }; 1683 + 1684 + export type CallWithResponsesErrors = { 1685 + /** 1686 + * Message for 500 error 1687 + */ 1688 + 500: ModelWithStringError; 1689 + /** 1690 + * Message for 501 error 1691 + */ 1692 + 501: ModelWithStringError; 1693 + /** 1694 + * Message for 502 error 1695 + */ 1696 + 502: ModelWithStringError; 1697 + /** 1698 + * Message for default response 1699 + */ 1700 + default: ModelWithStringError; 1701 + }; 1702 + 1703 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1704 + 1705 + export type CallWithResponsesResponses = { 1706 + /** 1707 + * Message for 200 response 1708 + */ 1709 + 200: { 1710 + readonly '@namespace.string'?: string; 1711 + readonly '@namespace.integer'?: number; 1712 + readonly value?: Array<ModelWithString>; 1713 + }; 1714 + /** 1715 + * Message for 201 response 1716 + */ 1717 + 201: ModelThatExtends; 1718 + /** 1719 + * Message for 202 response 1720 + */ 1721 + 202: ModelThatExtendsExtends; 1722 + }; 1723 + 1724 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1725 + 1726 + export type CollectionFormatData = { 1727 + body?: never; 1728 + path?: never; 1729 + query: { 1730 + /** 1731 + * This is an array parameter that is sent as csv format (comma-separated values) 1732 + */ 1733 + parameterArrayCSV: Array<string> | null; 1734 + /** 1735 + * This is an array parameter that is sent as ssv format (space-separated values) 1736 + */ 1737 + parameterArraySSV: Array<string> | null; 1738 + /** 1739 + * This is an array parameter that is sent as tsv format (tab-separated values) 1740 + */ 1741 + parameterArrayTSV: Array<string> | null; 1742 + /** 1743 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1744 + */ 1745 + parameterArrayPipes: Array<string> | null; 1746 + /** 1747 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1748 + */ 1749 + parameterArrayMulti: Array<string> | null; 1750 + }; 1751 + url: '/api/v{api-version}/collectionFormat'; 1752 + }; 1753 + 1754 + export type TypesData = { 1755 + body?: never; 1756 + path?: { 1757 + /** 1758 + * This is a number parameter 1759 + */ 1760 + id?: number; 1761 + }; 1762 + query: { 1763 + /** 1764 + * This is a number parameter 1765 + */ 1766 + parameterNumber: number; 1767 + /** 1768 + * This is a string parameter 1769 + */ 1770 + parameterString: string | null; 1771 + /** 1772 + * This is a boolean parameter 1773 + */ 1774 + parameterBoolean: boolean | null; 1775 + /** 1776 + * This is an object parameter 1777 + */ 1778 + parameterObject: { 1779 + [key: string]: unknown; 1780 + } | null; 1781 + /** 1782 + * This is an array parameter 1783 + */ 1784 + parameterArray: Array<string> | null; 1785 + /** 1786 + * This is a dictionary parameter 1787 + */ 1788 + parameterDictionary: { 1789 + [key: string]: unknown; 1790 + } | null; 1791 + /** 1792 + * This is an enum parameter 1793 + */ 1794 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1795 + }; 1796 + url: '/api/v{api-version}/types'; 1797 + }; 1798 + 1799 + export type TypesResponses = { 1800 + /** 1801 + * Response is a simple number 1802 + */ 1803 + 200: number; 1804 + /** 1805 + * Response is a simple string 1806 + */ 1807 + 201: string; 1808 + /** 1809 + * Response is a simple boolean 1810 + */ 1811 + 202: boolean; 1812 + /** 1813 + * Response is a simple object 1814 + */ 1815 + 203: { 1816 + [key: string]: unknown; 1817 + }; 1818 + }; 1819 + 1820 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1821 + 1822 + export type UploadFileData = { 1823 + body: Blob | File; 1824 + path: { 1825 + /** 1826 + * api-version should be required in standalone clients 1827 + */ 1828 + 'api-version': string | null; 1829 + }; 1830 + query?: never; 1831 + url: '/api/v{api-version}/upload'; 1832 + }; 1833 + 1834 + export type UploadFileResponses = { 1835 + 200: boolean; 1836 + }; 1837 + 1838 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1839 + 1840 + export type FileResponseData = { 1841 + body?: never; 1842 + path: { 1843 + id: string; 1844 + /** 1845 + * api-version should be required in standalone clients 1846 + */ 1847 + 'api-version': string; 1848 + }; 1849 + query?: never; 1850 + url: '/api/v{api-version}/file/{id}'; 1851 + }; 1852 + 1853 + export type FileResponseResponses = { 1854 + /** 1855 + * Success 1856 + */ 1857 + 200: Blob | File; 1858 + }; 1859 + 1860 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1861 + 1862 + export type ComplexTypesData = { 1863 + body?: never; 1864 + path?: never; 1865 + query: { 1866 + /** 1867 + * Parameter containing object 1868 + */ 1869 + parameterObject: { 1870 + first?: { 1871 + second?: { 1872 + third?: string; 1873 + }; 1874 + }; 1875 + }; 1876 + /** 1877 + * Parameter containing reference 1878 + */ 1879 + parameterReference: ModelWithString; 1880 + }; 1881 + url: '/api/v{api-version}/complex'; 1882 + }; 1883 + 1884 + export type ComplexTypesErrors = { 1885 + /** 1886 + * 400 `server` error 1887 + */ 1888 + 400: unknown; 1889 + /** 1890 + * 500 server error 1891 + */ 1892 + 500: unknown; 1893 + }; 1894 + 1895 + export type ComplexTypesResponses = { 1896 + /** 1897 + * Successful response 1898 + */ 1899 + 200: Array<ModelWithString>; 1900 + }; 1901 + 1902 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1903 + 1904 + export type MultipartResponseData = { 1905 + body?: never; 1906 + path?: never; 1907 + query?: never; 1908 + url: '/api/v{api-version}/multipart'; 1909 + }; 1910 + 1911 + export type MultipartResponseResponses = { 1912 + /** 1913 + * OK 1914 + */ 1915 + 200: { 1916 + file?: Blob | File; 1917 + metadata?: { 1918 + foo?: string; 1919 + bar?: string; 1920 + }; 1921 + }; 1922 + }; 1923 + 1924 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1925 + 1926 + export type MultipartRequestData = { 1927 + body?: { 1928 + content?: Blob | File; 1929 + data?: ModelWithString | null; 1930 + }; 1931 + path?: never; 1932 + query?: never; 1933 + url: '/api/v{api-version}/multipart'; 1934 + }; 1935 + 1936 + export type ComplexParamsData = { 1937 + body?: { 1938 + readonly key: string | null; 1939 + name: string | null; 1940 + enabled?: boolean; 1941 + type: 'Monkey' | 'Horse' | 'Bird'; 1942 + listOfModels?: Array<ModelWithString> | null; 1943 + listOfStrings?: Array<string> | null; 1944 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1945 + readonly user?: { 1946 + readonly id?: number; 1947 + readonly name?: string | null; 1948 + }; 1949 + }; 1950 + path: { 1951 + id: number; 1952 + /** 1953 + * api-version should be required in standalone clients 1954 + */ 1955 + 'api-version': string; 1956 + }; 1957 + query?: never; 1958 + url: '/api/v{api-version}/complex/{id}'; 1959 + }; 1960 + 1961 + export type ComplexParamsResponses = { 1962 + /** 1963 + * Success 1964 + */ 1965 + 200: ModelWithString; 1966 + }; 1967 + 1968 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1969 + 1970 + export type CallWithResultFromHeaderData = { 1971 + body?: never; 1972 + path?: never; 1973 + query?: never; 1974 + url: '/api/v{api-version}/header'; 1975 + }; 1976 + 1977 + export type CallWithResultFromHeaderErrors = { 1978 + /** 1979 + * 400 server error 1980 + */ 1981 + 400: unknown; 1982 + /** 1983 + * 500 server error 1984 + */ 1985 + 500: unknown; 1986 + }; 1987 + 1988 + export type CallWithResultFromHeaderResponses = { 1989 + /** 1990 + * Successful response 1991 + */ 1992 + 200: unknown; 1993 + }; 1994 + 1995 + export type TestErrorCodeData = { 1996 + body?: never; 1997 + path?: never; 1998 + query: { 1999 + /** 2000 + * Status code to return 2001 + */ 2002 + status: number; 2003 + }; 2004 + url: '/api/v{api-version}/error'; 2005 + }; 2006 + 2007 + export type TestErrorCodeErrors = { 2008 + /** 2009 + * Custom message: Internal Server Error 2010 + */ 2011 + 500: unknown; 2012 + /** 2013 + * Custom message: Not Implemented 2014 + */ 2015 + 501: unknown; 2016 + /** 2017 + * Custom message: Bad Gateway 2018 + */ 2019 + 502: unknown; 2020 + /** 2021 + * Custom message: Service Unavailable 2022 + */ 2023 + 503: unknown; 2024 + }; 2025 + 2026 + export type TestErrorCodeResponses = { 2027 + /** 2028 + * Custom message: Successful response 2029 + */ 2030 + 200: unknown; 2031 + }; 2032 + 2033 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2034 + body?: never; 2035 + path?: never; 2036 + query: { 2037 + /** 2038 + * Dummy input param 2039 + */ 2040 + nonAsciiParamæøåÆØÅöôêÊ: number; 2041 + }; 2042 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2043 + }; 2044 + 2045 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2046 + /** 2047 + * Successful response 2048 + */ 2049 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2050 + }; 2051 + 2052 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2053 + 2054 + export type PutWithFormUrlEncodedData = { 2055 + body: ArrayWithStrings; 2056 + path?: never; 2057 + query?: never; 2058 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2059 + }; 2060 + 2061 + export type ClientOptions = { 2062 + baseUrl: 'http://localhost:3000/base' | (string & {}); 2063 + };
+18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ClientOptions } from './types.gen'; 4 + import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions>({ 17 + baseUrl: 'http://localhost:3000/base' 18 + }));
+259
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createSseClient } from '../core/serverSentEvents.gen'; 4 + import type { HttpMethod } from '../core/types.gen'; 5 + import type { 6 + Client, 7 + Config, 8 + RequestOptions, 9 + ResolvedRequestOptions, 10 + } from './types.gen'; 11 + import { 12 + buildUrl, 13 + createConfig, 14 + createInterceptors, 15 + getParseAs, 16 + mergeConfigs, 17 + mergeHeaders, 18 + setAuthParams, 19 + } from './utils.gen'; 20 + 21 + type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 22 + body?: any; 23 + headers: ReturnType<typeof mergeHeaders>; 24 + }; 25 + 26 + export const createClient = (config: Config = {}): Client => { 27 + let _config = mergeConfigs(createConfig(), config); 28 + 29 + const getConfig = (): Config => ({ ..._config }); 30 + 31 + const setConfig = (config: Config): Config => { 32 + _config = mergeConfigs(_config, config); 33 + return getConfig(); 34 + }; 35 + 36 + const interceptors = createInterceptors< 37 + Response, 38 + unknown, 39 + ResolvedRequestOptions 40 + >(); 41 + 42 + const beforeRequest = async (options: RequestOptions) => { 43 + const opts = { 44 + ..._config, 45 + ...options, 46 + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 47 + headers: mergeHeaders(_config.headers, options.headers), 48 + serializedBody: undefined, 49 + }; 50 + 51 + if (opts.security) { 52 + await setAuthParams({ 53 + ...opts, 54 + security: opts.security, 55 + }); 56 + } 57 + 58 + if (opts.requestValidator) { 59 + await opts.requestValidator(opts); 60 + } 61 + 62 + if (opts.body && opts.bodySerializer) { 63 + opts.serializedBody = opts.bodySerializer(opts.body); 64 + } 65 + 66 + // remove Content-Type header if body is empty to avoid sending invalid requests 67 + if (opts.serializedBody === undefined || opts.serializedBody === '') { 68 + opts.headers.delete('Content-Type'); 69 + } 70 + 71 + const url = buildUrl(opts); 72 + 73 + return { opts, url }; 74 + }; 75 + 76 + // @ts-expect-error 77 + const request: Client['request'] = async (options) => { 78 + // @ts-expect-error 79 + const { opts, url } = await beforeRequest(options); 80 + 81 + for (const fn of interceptors.request._fns) { 82 + if (fn) { 83 + await fn(opts); 84 + } 85 + } 86 + 87 + // fetch must be assigned here, otherwise it would throw the error: 88 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 89 + const _fetch = opts.fetch!; 90 + let response = await _fetch(url, { 91 + ...opts, 92 + body: opts.serializedBody as ReqInit['body'], 93 + }); 94 + 95 + for (const fn of interceptors.response._fns) { 96 + if (fn) { 97 + response = await fn(response, opts); 98 + } 99 + } 100 + 101 + const result = { 102 + response, 103 + }; 104 + 105 + if (response.ok) { 106 + const parseAs = 107 + (opts.parseAs === 'auto' 108 + ? getParseAs(response.headers.get('Content-Type')) 109 + : opts.parseAs) ?? 'json'; 110 + 111 + if ( 112 + response.status === 204 || 113 + response.headers.get('Content-Length') === '0' 114 + ) { 115 + let emptyData: any; 116 + switch (parseAs) { 117 + case 'arrayBuffer': 118 + case 'blob': 119 + case 'text': 120 + emptyData = await response[parseAs](); 121 + break; 122 + case 'formData': 123 + emptyData = new FormData(); 124 + break; 125 + case 'stream': 126 + emptyData = response.body; 127 + break; 128 + case 'json': 129 + default: 130 + emptyData = {}; 131 + break; 132 + } 133 + return { 134 + data: emptyData, 135 + ...result, 136 + }; 137 + } 138 + 139 + let data: any; 140 + switch (parseAs) { 141 + case 'arrayBuffer': 142 + case 'blob': 143 + case 'formData': 144 + case 'json': 145 + case 'text': 146 + data = await response[parseAs](); 147 + break; 148 + case 'stream': 149 + return { 150 + data: response.body, 151 + ...result, 152 + }; 153 + } 154 + 155 + if (parseAs === 'json') { 156 + if (opts.responseValidator) { 157 + await opts.responseValidator(data); 158 + } 159 + 160 + if (opts.responseTransformer) { 161 + data = await opts.responseTransformer(data); 162 + } 163 + } 164 + 165 + return { 166 + data, 167 + ...result, 168 + }; 169 + } 170 + 171 + const textError = await response.text(); 172 + let jsonError: unknown; 173 + 174 + try { 175 + jsonError = JSON.parse(textError); 176 + } catch { 177 + // noop 178 + } 179 + 180 + const error = jsonError ?? textError; 181 + let finalError = error; 182 + 183 + for (const fn of interceptors.error._fns) { 184 + if (fn) { 185 + finalError = (await fn(error, response, opts)) as string; 186 + } 187 + } 188 + 189 + finalError = finalError || ({} as string); 190 + 191 + if (opts.throwOnError) { 192 + throw finalError; 193 + } 194 + 195 + return { 196 + error: finalError, 197 + ...result, 198 + }; 199 + }; 200 + 201 + const makeMethodFn = 202 + (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 203 + request({ ...options, method }); 204 + 205 + const makeSseFn = 206 + (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 207 + const { opts, url } = await beforeRequest(options); 208 + return createSseClient({ 209 + ...opts, 210 + body: opts.body as BodyInit | null | undefined, 211 + headers: opts.headers as unknown as Record<string, string>, 212 + method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 228 + url, 229 + }); 230 + }; 231 + 232 + return { 233 + buildUrl, 234 + connect: makeMethodFn('CONNECT'), 235 + delete: makeMethodFn('DELETE'), 236 + get: makeMethodFn('GET'), 237 + getConfig, 238 + head: makeMethodFn('HEAD'), 239 + interceptors, 240 + options: makeMethodFn('OPTIONS'), 241 + patch: makeMethodFn('PATCH'), 242 + post: makeMethodFn('POST'), 243 + put: makeMethodFn('PUT'), 244 + request, 245 + setConfig, 246 + sse: { 247 + connect: makeSseFn('CONNECT'), 248 + delete: makeSseFn('DELETE'), 249 + get: makeSseFn('GET'), 250 + head: makeSseFn('HEAD'), 251 + options: makeSseFn('OPTIONS'), 252 + patch: makeSseFn('PATCH'), 253 + post: makeSseFn('POST'), 254 + put: makeSseFn('PUT'), 255 + trace: makeSseFn('TRACE'), 256 + }, 257 + trace: makeMethodFn('TRACE'), 258 + } as Client; 259 + };
+23
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { createClient } from './client.gen'; 12 + export type { 13 + Client, 14 + ClientOptions, 15 + Config, 16 + CreateClientConfig, 17 + Options, 18 + OptionsLegacyParser, 19 + RequestOptions, 20 + RequestResult, 21 + TDataShape, 22 + } from './types.gen'; 23 + export { createConfig } from './utils.gen';
+217
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth } from '../core/auth.gen'; 4 + import type { 5 + ServerSentEventsOptions, 6 + ServerSentEventsResult, 7 + } from '../core/serverSentEvents.gen'; 8 + import type { 9 + Client as CoreClient, 10 + Config as CoreConfig, 11 + } from '../core/types.gen'; 12 + import type { Middleware } from './utils.gen'; 13 + 14 + export interface Config<T extends ClientOptions = ClientOptions> 15 + extends Omit<RequestInit, 'body' | 'headers' | 'method'>, 16 + CoreConfig { 17 + /** 18 + * Base URL for all requests made by this client. 19 + */ 20 + baseUrl?: T['baseUrl']; 21 + /** 22 + * Fetch API implementation. You can use this option to provide a custom 23 + * fetch instance. 24 + * 25 + * @default globalThis.fetch 26 + */ 27 + fetch?: typeof fetch; 28 + /** 29 + * Return the response data parsed in a specified format. By default, `auto` 30 + * will infer the appropriate method from the `Content-Type` response header. 31 + * You can override this behavior with any of the {@link Body} methods. 32 + * Select `stream` if you don't want to parse response data at all. 33 + * 34 + * @default 'auto' 35 + */ 36 + parseAs?: 37 + | 'arrayBuffer' 38 + | 'auto' 39 + | 'blob' 40 + | 'formData' 41 + | 'json' 42 + | 'stream' 43 + | 'text'; 44 + /** 45 + * Throw an error instead of returning it in the response? 46 + * 47 + * @default false 48 + */ 49 + throwOnError?: T['throwOnError']; 50 + } 51 + 52 + export interface RequestOptions< 53 + TData = unknown, 54 + ThrowOnError extends boolean = boolean, 55 + Url extends string = string, 56 + > extends Config<{ 57 + throwOnError: ThrowOnError; 58 + }>, 59 + Pick< 60 + ServerSentEventsOptions<TData>, 61 + | 'onSseError' 62 + | 'onSseEvent' 63 + | 'sseDefaultRetryDelay' 64 + | 'sseMaxRetryAttempts' 65 + | 'sseMaxRetryDelay' 66 + > { 67 + /** 68 + * Any body that you want to add to your request. 69 + * 70 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 71 + */ 72 + body?: unknown; 73 + path?: Record<string, unknown>; 74 + query?: Record<string, unknown>; 75 + /** 76 + * Security mechanism(s) to use for the request. 77 + */ 78 + security?: ReadonlyArray<Auth>; 79 + url: Url; 80 + } 81 + 82 + export interface ResolvedRequestOptions< 83 + ThrowOnError extends boolean = boolean, 84 + Url extends string = string, 85 + > extends RequestOptions<unknown, ThrowOnError, Url> { 86 + serializedBody?: string; 87 + } 88 + 89 + export type RequestResult< 90 + TData = unknown, 91 + TError = unknown, 92 + ThrowOnError extends boolean = boolean, 93 + > = ThrowOnError extends true 94 + ? Promise<{ 95 + data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 96 + response: Response; 97 + }> 98 + : Promise< 99 + ( 100 + | { 101 + data: TData extends Record<string, unknown> 102 + ? TData[keyof TData] 103 + : TData; 104 + error: undefined; 105 + } 106 + | { 107 + data: undefined; 108 + error: TError extends Record<string, unknown> 109 + ? TError[keyof TError] 110 + : TError; 111 + } 112 + ) & { 113 + response: Response; 114 + } 115 + >; 116 + 117 + export interface ClientOptions { 118 + baseUrl?: string; 119 + throwOnError?: boolean; 120 + } 121 + 122 + type MethodFn = < 123 + TData = unknown, 124 + TError = unknown, 125 + ThrowOnError extends boolean = false, 126 + >( 127 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>, 128 + ) => RequestResult<TData, TError, ThrowOnError>; 129 + 130 + type SseFn = < 131 + TData = unknown, 132 + TError = unknown, 133 + ThrowOnError extends boolean = false, 134 + >( 135 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>, 136 + ) => Promise<ServerSentEventsResult<TData, TError>>; 137 + 138 + type RequestFn = < 139 + TData = unknown, 140 + TError = unknown, 141 + ThrowOnError extends boolean = false, 142 + >( 143 + options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> & 144 + Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>, 145 + ) => RequestResult<TData, TError, ThrowOnError>; 146 + 147 + type BuildUrlFn = < 148 + TData extends { 149 + body?: unknown; 150 + path?: Record<string, unknown>; 151 + query?: Record<string, unknown>; 152 + url: string; 153 + }, 154 + >( 155 + options: Pick<TData, 'url'> & Options<TData>, 156 + ) => string; 157 + 158 + export type Client = CoreClient< 159 + RequestFn, 160 + Config, 161 + MethodFn, 162 + BuildUrlFn, 163 + SseFn 164 + > & { 165 + interceptors: Middleware<Response, unknown, ResolvedRequestOptions>; 166 + }; 167 + 168 + /** 169 + * The `createClientConfig()` function will be called on client initialization 170 + * and the returned object will become the client's initial configuration. 171 + * 172 + * You may want to initialize your client this way instead of calling 173 + * `setConfig()`. This is useful for example if you're using Next.js 174 + * to ensure your client always has the correct values. 175 + */ 176 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 177 + override?: Config<ClientOptions & T>, 178 + ) => Config<Required<ClientOptions> & T>; 179 + 180 + export interface TDataShape { 181 + body?: unknown; 182 + headers?: unknown; 183 + path?: unknown; 184 + query?: unknown; 185 + url: string; 186 + } 187 + 188 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 189 + 190 + export type Options< 191 + TData extends TDataShape = TDataShape, 192 + ThrowOnError extends boolean = boolean, 193 + TResponse = unknown, 194 + > = OmitKeys< 195 + RequestOptions<TResponse, ThrowOnError>, 196 + 'body' | 'path' | 'query' | 'url' 197 + > & 198 + Omit<TData, 'url'>; 199 + 200 + export type OptionsLegacyParser< 201 + TData = unknown, 202 + ThrowOnError extends boolean = boolean, 203 + > = TData extends { body?: any } 204 + ? TData extends { headers?: any } 205 + ? OmitKeys< 206 + RequestOptions<unknown, ThrowOnError>, 207 + 'body' | 'headers' | 'url' 208 + > & 209 + TData 210 + : OmitKeys<RequestOptions<unknown, ThrowOnError>, 'body' | 'url'> & 211 + TData & 212 + Pick<RequestOptions<unknown, ThrowOnError>, 'headers'> 213 + : TData extends { headers?: any } 214 + ? OmitKeys<RequestOptions<unknown, ThrowOnError>, 'headers' | 'url'> & 215 + TData & 216 + Pick<RequestOptions<unknown, ThrowOnError>, 'body'> 217 + : OmitKeys<RequestOptions<unknown, ThrowOnError>, 'url'> & TData;
+428
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { getAuthToken } from '../core/auth.gen'; 4 + import type { 5 + QuerySerializer, 6 + QuerySerializerOptions, 7 + } from '../core/bodySerializer.gen'; 8 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 9 + import { 10 + serializeArrayParam, 11 + serializeObjectParam, 12 + serializePrimitiveParam, 13 + } from '../core/pathSerializer.gen'; 14 + import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 15 + 16 + interface PathSerializer { 17 + path: Record<string, unknown>; 18 + url: string; 19 + } 20 + 21 + const PATH_PARAM_RE = /\{[^{}]+\}/g; 22 + 23 + type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 24 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 25 + type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 26 + 27 + const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 28 + let url = _url; 29 + const matches = _url.match(PATH_PARAM_RE); 30 + if (matches) { 31 + for (const match of matches) { 32 + let explode = false; 33 + let name = match.substring(1, match.length - 1); 34 + let style: ArraySeparatorStyle = 'simple'; 35 + 36 + if (name.endsWith('*')) { 37 + explode = true; 38 + name = name.substring(0, name.length - 1); 39 + } 40 + 41 + if (name.startsWith('.')) { 42 + name = name.substring(1); 43 + style = 'label'; 44 + } else if (name.startsWith(';')) { 45 + name = name.substring(1); 46 + style = 'matrix'; 47 + } 48 + 49 + const value = path[name]; 50 + 51 + if (value === undefined || value === null) { 52 + continue; 53 + } 54 + 55 + if (Array.isArray(value)) { 56 + url = url.replace( 57 + match, 58 + serializeArrayParam({ explode, name, style, value }), 59 + ); 60 + continue; 61 + } 62 + 63 + if (typeof value === 'object') { 64 + url = url.replace( 65 + match, 66 + serializeObjectParam({ 67 + explode, 68 + name, 69 + style, 70 + value: value as Record<string, unknown>, 71 + valueOnly: true, 72 + }), 73 + ); 74 + continue; 75 + } 76 + 77 + if (style === 'matrix') { 78 + url = url.replace( 79 + match, 80 + `;${serializePrimitiveParam({ 81 + name, 82 + value: value as string, 83 + })}`, 84 + ); 85 + continue; 86 + } 87 + 88 + const replaceValue = encodeURIComponent( 89 + style === 'label' ? `.${value as string}` : (value as string), 90 + ); 91 + url = url.replace(match, replaceValue); 92 + } 93 + } 94 + return url; 95 + }; 96 + 97 + export const createQuerySerializer = <T = unknown>({ 98 + allowReserved, 99 + array, 100 + object, 101 + }: QuerySerializerOptions = {}) => { 102 + const querySerializer = (queryParams: T) => { 103 + const search: string[] = []; 104 + if (queryParams && typeof queryParams === 'object') { 105 + for (const name in queryParams) { 106 + const value = queryParams[name]; 107 + 108 + if (value === undefined || value === null) { 109 + continue; 110 + } 111 + 112 + if (Array.isArray(value)) { 113 + const serializedArray = serializeArrayParam({ 114 + allowReserved, 115 + explode: true, 116 + name, 117 + style: 'form', 118 + value, 119 + ...array, 120 + }); 121 + if (serializedArray) search.push(serializedArray); 122 + } else if (typeof value === 'object') { 123 + const serializedObject = serializeObjectParam({ 124 + allowReserved, 125 + explode: true, 126 + name, 127 + style: 'deepObject', 128 + value: value as Record<string, unknown>, 129 + ...object, 130 + }); 131 + if (serializedObject) search.push(serializedObject); 132 + } else { 133 + const serializedPrimitive = serializePrimitiveParam({ 134 + allowReserved, 135 + name, 136 + value: value as string, 137 + }); 138 + if (serializedPrimitive) search.push(serializedPrimitive); 139 + } 140 + } 141 + } 142 + return search.join('&'); 143 + }; 144 + return querySerializer; 145 + }; 146 + 147 + /** 148 + * Infers parseAs value from provided Content-Type header. 149 + */ 150 + export const getParseAs = ( 151 + contentType: string | null, 152 + ): Exclude<Config['parseAs'], 'auto'> => { 153 + if (!contentType) { 154 + // If no Content-Type header is provided, the best we can do is return the raw response body, 155 + // which is effectively the same as the 'stream' option. 156 + return 'stream'; 157 + } 158 + 159 + const cleanContent = contentType.split(';')[0]?.trim(); 160 + 161 + if (!cleanContent) { 162 + return; 163 + } 164 + 165 + if ( 166 + cleanContent.startsWith('application/json') || 167 + cleanContent.endsWith('+json') 168 + ) { 169 + return 'json'; 170 + } 171 + 172 + if (cleanContent === 'multipart/form-data') { 173 + return 'formData'; 174 + } 175 + 176 + if ( 177 + ['application/', 'audio/', 'image/', 'video/'].some((type) => 178 + cleanContent.startsWith(type), 179 + ) 180 + ) { 181 + return 'blob'; 182 + } 183 + 184 + if (cleanContent.startsWith('text/')) { 185 + return 'text'; 186 + } 187 + 188 + return; 189 + }; 190 + 191 + const checkForExistence = ( 192 + options: Pick<RequestOptions, 'auth' | 'query'> & { 193 + headers: Headers; 194 + }, 195 + name?: string, 196 + ): boolean => { 197 + if (!name) { 198 + return false; 199 + } 200 + if ( 201 + options.headers.has(name) || 202 + options.query?.[name] || 203 + options.headers.get('Cookie')?.includes(`${name}=`) 204 + ) { 205 + return true; 206 + } 207 + return false; 208 + }; 209 + 210 + export const setAuthParams = async ({ 211 + security, 212 + ...options 213 + }: Pick<Required<RequestOptions>, 'security'> & 214 + Pick<RequestOptions, 'auth' | 'query'> & { 215 + headers: Headers; 216 + }) => { 217 + for (const auth of security) { 218 + if (checkForExistence(options, auth.name)) { 219 + continue; 220 + } 221 + const token = await getAuthToken(auth, options.auth); 222 + 223 + if (!token) { 224 + continue; 225 + } 226 + 227 + const name = auth.name ?? 'Authorization'; 228 + 229 + switch (auth.in) { 230 + case 'query': 231 + if (!options.query) { 232 + options.query = {}; 233 + } 234 + options.query[name] = token; 235 + break; 236 + case 'cookie': 237 + options.headers.append('Cookie', `${name}=${token}`); 238 + break; 239 + case 'header': 240 + default: 241 + options.headers.set(name, token); 242 + break; 243 + } 244 + } 245 + }; 246 + 247 + export const buildUrl: Client['buildUrl'] = (options) => { 248 + const url = getUrl({ 249 + baseUrl: options.baseUrl as string, 250 + path: options.path, 251 + query: options.query, 252 + querySerializer: 253 + typeof options.querySerializer === 'function' 254 + ? options.querySerializer 255 + : createQuerySerializer(options.querySerializer), 256 + url: options.url, 257 + }); 258 + return url; 259 + }; 260 + 261 + export const getUrl = ({ 262 + baseUrl, 263 + path, 264 + query, 265 + querySerializer, 266 + url: _url, 267 + }: { 268 + baseUrl?: string; 269 + path?: Record<string, unknown>; 270 + query?: Record<string, unknown>; 271 + querySerializer: QuerySerializer; 272 + url: string; 273 + }) => { 274 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 275 + let url = (baseUrl ?? '') + pathUrl; 276 + if (path) { 277 + url = defaultPathSerializer({ path, url }); 278 + } 279 + let search = query ? querySerializer(query) : ''; 280 + if (search.startsWith('?')) { 281 + search = search.substring(1); 282 + } 283 + if (search) { 284 + url += `?${search}`; 285 + } 286 + return url; 287 + }; 288 + 289 + export const mergeConfigs = (a: Config, b: Config): Config => { 290 + const config = { ...a, ...b }; 291 + if (config.baseUrl?.endsWith('/')) { 292 + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 293 + } 294 + config.headers = mergeHeaders(a.headers, b.headers); 295 + return config; 296 + }; 297 + 298 + export const mergeHeaders = ( 299 + ...headers: Array<Required<Config>['headers'] | undefined> 300 + ): Headers => { 301 + const mergedHeaders = new Headers(); 302 + for (const header of headers) { 303 + if (!header || typeof header !== 'object') { 304 + continue; 305 + } 306 + 307 + const iterator = 308 + header instanceof Headers ? header.entries() : Object.entries(header); 309 + 310 + for (const [key, value] of iterator) { 311 + if (value === null) { 312 + mergedHeaders.delete(key); 313 + } else if (Array.isArray(value)) { 314 + for (const v of value) { 315 + mergedHeaders.append(key, v as string); 316 + } 317 + } else if (value !== undefined) { 318 + // assume object headers are meant to be JSON stringified, i.e. their 319 + // content value in OpenAPI specification is 'application/json' 320 + mergedHeaders.set( 321 + key, 322 + typeof value === 'object' ? JSON.stringify(value) : (value as string), 323 + ); 324 + } 325 + } 326 + } 327 + return mergedHeaders; 328 + }; 329 + 330 + type ErrInterceptor<Err, Res, Options> = ( 331 + error: Err, 332 + response: Res, 333 + options: Options, 334 + ) => Err | Promise<Err>; 335 + 336 + type ReqInterceptor<Options> = (options: Options) => void | Promise<void>; 337 + 338 + type ResInterceptor<Res, Options> = ( 339 + response: Res, 340 + options: Options, 341 + ) => Res | Promise<Res>; 342 + 343 + class Interceptors<Interceptor> { 344 + _fns: (Interceptor | null)[]; 345 + 346 + constructor() { 347 + this._fns = []; 348 + } 349 + 350 + clear() { 351 + this._fns = []; 352 + } 353 + 354 + getInterceptorIndex(id: number | Interceptor): number { 355 + if (typeof id === 'number') { 356 + return this._fns[id] ? id : -1; 357 + } else { 358 + return this._fns.indexOf(id); 359 + } 360 + } 361 + exists(id: number | Interceptor) { 362 + const index = this.getInterceptorIndex(id); 363 + return !!this._fns[index]; 364 + } 365 + 366 + eject(id: number | Interceptor) { 367 + const index = this.getInterceptorIndex(id); 368 + if (this._fns[index]) { 369 + this._fns[index] = null; 370 + } 371 + } 372 + 373 + update(id: number | Interceptor, fn: Interceptor) { 374 + const index = this.getInterceptorIndex(id); 375 + if (this._fns[index]) { 376 + this._fns[index] = fn; 377 + return id; 378 + } else { 379 + return false; 380 + } 381 + } 382 + 383 + use(fn: Interceptor) { 384 + this._fns = [...this._fns, fn]; 385 + return this._fns.length - 1; 386 + } 387 + } 388 + 389 + // `createInterceptors()` response, meant for external use as it does not 390 + // expose internals 391 + export interface Middleware<Res, Err, Options> { 392 + error: Pick<Interceptors<ErrInterceptor<Err, Res, Options>>, 'eject' | 'use'>; 393 + request: Pick<Interceptors<ReqInterceptor<Options>>, 'eject' | 'use'>; 394 + response: Pick<Interceptors<ResInterceptor<Res, Options>>, 'eject' | 'use'>; 395 + } 396 + 397 + // do not add `Middleware` as return type so we can use _fns internally 398 + export const createInterceptors = <Res, Err, Options>() => ({ 399 + error: new Interceptors<ErrInterceptor<Err, Res, Options>>(), 400 + request: new Interceptors<ReqInterceptor<Options>>(), 401 + response: new Interceptors<ResInterceptor<Res, Options>>(), 402 + }); 403 + 404 + const defaultQuerySerializer = createQuerySerializer({ 405 + allowReserved: false, 406 + array: { 407 + explode: true, 408 + style: 'form', 409 + }, 410 + object: { 411 + explode: true, 412 + style: 'deepObject', 413 + }, 414 + }); 415 + 416 + const defaultHeaders = { 417 + 'Content-Type': 'application/json', 418 + }; 419 + 420 + export const createConfig = <T extends ClientOptions = ClientOptions>( 421 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 422 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 423 + ...jsonBodySerializer, 424 + headers: defaultHeaders, 425 + parseAs: 'auto', 426 + querySerializer: defaultQuerySerializer, 427 + ...override, 428 + });
+42
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = 27 + typeof callback === 'function' ? await callback(auth) : callback; 28 + 29 + if (!token) { 30 + return; 31 + } 32 + 33 + if (auth.scheme === 'bearer') { 34 + return `Bearer ${token}`; 35 + } 36 + 37 + if (auth.scheme === 'basic') { 38 + return `Basic ${btoa(token)}`; 39 + } 40 + 41 + return token; 42 + };
+92
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + ArrayStyle, 5 + ObjectStyle, 6 + SerializerOptions, 7 + } from './pathSerializer.gen'; 8 + 9 + export type QuerySerializer = (query: Record<string, unknown>) => string; 10 + 11 + export type BodySerializer = (body: any) => any; 12 + 13 + export interface QuerySerializerOptions { 14 + allowReserved?: boolean; 15 + array?: SerializerOptions<ArrayStyle>; 16 + object?: SerializerOptions<ObjectStyle>; 17 + } 18 + 19 + const serializeFormDataPair = ( 20 + data: FormData, 21 + key: string, 22 + value: unknown, 23 + ): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = ( 34 + data: URLSearchParams, 35 + key: string, 36 + value: unknown, 37 + ): void => { 38 + if (typeof value === 'string') { 39 + data.append(key, value); 40 + } else { 41 + data.append(key, JSON.stringify(value)); 42 + } 43 + }; 44 + 45 + export const formDataBodySerializer = { 46 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 47 + body: T, 48 + ): FormData => { 49 + const data = new FormData(); 50 + 51 + Object.entries(body).forEach(([key, value]) => { 52 + if (value === undefined || value === null) { 53 + return; 54 + } 55 + if (Array.isArray(value)) { 56 + value.forEach((v) => serializeFormDataPair(data, key, v)); 57 + } else { 58 + serializeFormDataPair(data, key, value); 59 + } 60 + }); 61 + 62 + return data; 63 + }, 64 + }; 65 + 66 + export const jsonBodySerializer = { 67 + bodySerializer: <T>(body: T): string => 68 + JSON.stringify(body, (_key, value) => 69 + typeof value === 'bigint' ? value.toString() : value, 70 + ), 71 + }; 72 + 73 + export const urlSearchParamsBodySerializer = { 74 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 75 + body: T, 76 + ): string => { 77 + const data = new URLSearchParams(); 78 + 79 + Object.entries(body).forEach(([key, value]) => { 80 + if (value === undefined || value === null) { 81 + return; 82 + } 83 + if (Array.isArray(value)) { 84 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 85 + } else { 86 + serializeUrlSearchParamsPair(data, key, value); 87 + } 88 + }); 89 + 90 + return data.toString(); 91 + }, 92 + };
+153
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + }; 26 + 27 + export interface Fields { 28 + allowExtra?: Partial<Record<Slot, boolean>>; 29 + args?: ReadonlyArray<Field>; 30 + } 31 + 32 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 33 + 34 + const extraPrefixesMap: Record<string, Slot> = { 35 + $body_: 'body', 36 + $headers_: 'headers', 37 + $path_: 'path', 38 + $query_: 'query', 39 + }; 40 + const extraPrefixes = Object.entries(extraPrefixesMap); 41 + 42 + type KeyMap = Map< 43 + string, 44 + { 45 + in: Slot; 46 + map?: string; 47 + } 48 + >; 49 + 50 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 51 + if (!map) { 52 + map = new Map(); 53 + } 54 + 55 + for (const config of fields) { 56 + if ('in' in config) { 57 + if (config.key) { 58 + map.set(config.key, { 59 + in: config.in, 60 + map: config.map, 61 + }); 62 + } 63 + } else if (config.args) { 64 + buildKeyMap(config.args, map); 65 + } 66 + } 67 + 68 + return map; 69 + }; 70 + 71 + interface Params { 72 + body: unknown; 73 + headers: Record<string, unknown>; 74 + path: Record<string, unknown>; 75 + query: Record<string, unknown>; 76 + } 77 + 78 + const stripEmptySlots = (params: Params) => { 79 + for (const [slot, value] of Object.entries(params)) { 80 + if (value && typeof value === 'object' && !Object.keys(value).length) { 81 + delete params[slot as Slot]; 82 + } 83 + } 84 + }; 85 + 86 + export const buildClientParams = ( 87 + args: ReadonlyArray<unknown>, 88 + fields: FieldsConfig, 89 + ) => { 90 + const params: Params = { 91 + body: {}, 92 + headers: {}, 93 + path: {}, 94 + query: {}, 95 + }; 96 + 97 + const map = buildKeyMap(fields); 98 + 99 + let config: FieldsConfig[number] | undefined; 100 + 101 + for (const [index, arg] of args.entries()) { 102 + if (fields[index]) { 103 + config = fields[index]; 104 + } 105 + 106 + if (!config) { 107 + continue; 108 + } 109 + 110 + if ('in' in config) { 111 + if (config.key) { 112 + const field = map.get(config.key)!; 113 + const name = field.map || config.key; 114 + (params[field.in] as Record<string, unknown>)[name] = arg; 115 + } else { 116 + params.body = arg; 117 + } 118 + } else { 119 + for (const [key, value] of Object.entries(arg ?? {})) { 120 + const field = map.get(key); 121 + 122 + if (field) { 123 + const name = field.map || key; 124 + (params[field.in] as Record<string, unknown>)[name] = value; 125 + } else { 126 + const extra = extraPrefixes.find(([prefix]) => 127 + key.startsWith(prefix), 128 + ); 129 + 130 + if (extra) { 131 + const [prefix, slot] = extra; 132 + (params[slot] as Record<string, unknown>)[ 133 + key.slice(prefix.length) 134 + ] = value; 135 + } else { 136 + for (const [slot, allowed] of Object.entries( 137 + config.allowExtra ?? {}, 138 + )) { 139 + if (allowed) { 140 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 141 + break; 142 + } 143 + } 144 + } 145 + } 146 + } 147 + } 148 + } 149 + 150 + stripEmptySlots(params); 151 + 152 + return params; 153 + };
+181
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> 4 + extends SerializePrimitiveOptions, 5 + SerializerOptions<T> {} 6 + 7 + interface SerializePrimitiveOptions { 8 + allowReserved?: boolean; 9 + name: string; 10 + } 11 + 12 + export interface SerializerOptions<T> { 13 + /** 14 + * @default true 15 + */ 16 + explode: boolean; 17 + style: T; 18 + } 19 + 20 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 21 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 22 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 23 + export type ObjectStyle = 'form' | 'deepObject'; 24 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 25 + 26 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 27 + value: string; 28 + } 29 + 30 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 31 + switch (style) { 32 + case 'label': 33 + return '.'; 34 + case 'matrix': 35 + return ';'; 36 + case 'simple': 37 + return ','; 38 + default: 39 + return '&'; 40 + } 41 + }; 42 + 43 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 44 + switch (style) { 45 + case 'form': 46 + return ','; 47 + case 'pipeDelimited': 48 + return '|'; 49 + case 'spaceDelimited': 50 + return '%20'; 51 + default: 52 + return ','; 53 + } 54 + }; 55 + 56 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 57 + switch (style) { 58 + case 'label': 59 + return '.'; 60 + case 'matrix': 61 + return ';'; 62 + case 'simple': 63 + return ','; 64 + default: 65 + return '&'; 66 + } 67 + }; 68 + 69 + export const serializeArrayParam = ({ 70 + allowReserved, 71 + explode, 72 + name, 73 + style, 74 + value, 75 + }: SerializeOptions<ArraySeparatorStyle> & { 76 + value: unknown[]; 77 + }) => { 78 + if (!explode) { 79 + const joinedValues = ( 80 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 81 + ).join(separatorArrayNoExplode(style)); 82 + switch (style) { 83 + case 'label': 84 + return `.${joinedValues}`; 85 + case 'matrix': 86 + return `;${name}=${joinedValues}`; 87 + case 'simple': 88 + return joinedValues; 89 + default: 90 + return `${name}=${joinedValues}`; 91 + } 92 + } 93 + 94 + const separator = separatorArrayExplode(style); 95 + const joinedValues = value 96 + .map((v) => { 97 + if (style === 'label' || style === 'simple') { 98 + return allowReserved ? v : encodeURIComponent(v as string); 99 + } 100 + 101 + return serializePrimitiveParam({ 102 + allowReserved, 103 + name, 104 + value: v as string, 105 + }); 106 + }) 107 + .join(separator); 108 + return style === 'label' || style === 'matrix' 109 + ? separator + joinedValues 110 + : joinedValues; 111 + }; 112 + 113 + export const serializePrimitiveParam = ({ 114 + allowReserved, 115 + name, 116 + value, 117 + }: SerializePrimitiveParam) => { 118 + if (value === undefined || value === null) { 119 + return ''; 120 + } 121 + 122 + if (typeof value === 'object') { 123 + throw new Error( 124 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 125 + ); 126 + } 127 + 128 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 129 + }; 130 + 131 + export const serializeObjectParam = ({ 132 + allowReserved, 133 + explode, 134 + name, 135 + style, 136 + value, 137 + valueOnly, 138 + }: SerializeOptions<ObjectSeparatorStyle> & { 139 + value: Record<string, unknown> | Date; 140 + valueOnly?: boolean; 141 + }) => { 142 + if (value instanceof Date) { 143 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 144 + } 145 + 146 + if (style !== 'deepObject' && !explode) { 147 + let values: string[] = []; 148 + Object.entries(value).forEach(([key, v]) => { 149 + values = [ 150 + ...values, 151 + key, 152 + allowReserved ? (v as string) : encodeURIComponent(v as string), 153 + ]; 154 + }); 155 + const joinedValues = values.join(','); 156 + switch (style) { 157 + case 'form': 158 + return `${name}=${joinedValues}`; 159 + case 'label': 160 + return `.${joinedValues}`; 161 + case 'matrix': 162 + return `;${name}=${joinedValues}`; 163 + default: 164 + return joinedValues; 165 + } 166 + } 167 + 168 + const separator = separatorObjectExplode(style); 169 + const joinedValues = Object.entries(value) 170 + .map(([key, v]) => 171 + serializePrimitiveParam({ 172 + allowReserved, 173 + name: style === 'deepObject' ? `${name}[${key}]` : key, 174 + value: v as string, 175 + }), 176 + ) 177 + .join(separator); 178 + return style === 'label' || style === 'matrix' 179 + ? separator + joinedValues 180 + : joinedValues; 181 + };
+264
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit< 6 + RequestInit, 7 + 'method' 8 + > & 9 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 + /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 22 + * Callback invoked when a network or parsing error occurs during streaming. 23 + * 24 + * This option applies only if the endpoint returns a stream of events. 25 + * 26 + * @param error The error that occurred. 27 + */ 28 + onSseError?: (error: unknown) => void; 29 + /** 30 + * Callback invoked when an event is streamed from the server. 31 + * 32 + * This option applies only if the endpoint returns a stream of events. 33 + * 34 + * @param event Event streamed from the server. 35 + * @returns Nothing (void). 36 + */ 37 + onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 39 + /** 40 + * Default retry delay in milliseconds. 41 + * 42 + * This option applies only if the endpoint returns a stream of events. 43 + * 44 + * @default 3000 45 + */ 46 + sseDefaultRetryDelay?: number; 47 + /** 48 + * Maximum number of retry attempts before giving up. 49 + */ 50 + sseMaxRetryAttempts?: number; 51 + /** 52 + * Maximum retry delay in milliseconds. 53 + * 54 + * Applies only when exponential backoff is used. 55 + * 56 + * This option applies only if the endpoint returns a stream of events. 57 + * 58 + * @default 30000 59 + */ 60 + sseMaxRetryDelay?: number; 61 + /** 62 + * Optional sleep function for retry backoff. 63 + * 64 + * Defaults to using `setTimeout`. 65 + */ 66 + sseSleepFn?: (ms: number) => Promise<void>; 67 + url: string; 68 + }; 69 + 70 + export interface StreamEvent<TData = unknown> { 71 + data: TData; 72 + event?: string; 73 + id?: string; 74 + retry?: number; 75 + } 76 + 77 + export type ServerSentEventsResult< 78 + TData = unknown, 79 + TReturn = void, 80 + TNext = unknown, 81 + > = { 82 + stream: AsyncGenerator< 83 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 84 + TReturn, 85 + TNext 86 + >; 87 + }; 88 + 89 + export const createSseClient = <TData = unknown>({ 90 + onRequest, 91 + onSseError, 92 + onSseEvent, 93 + responseTransformer, 94 + responseValidator, 95 + sseDefaultRetryDelay, 96 + sseMaxRetryAttempts, 97 + sseMaxRetryDelay, 98 + sseSleepFn, 99 + url, 100 + ...options 101 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 102 + let lastEventId: string | undefined; 103 + 104 + const sleep = 105 + sseSleepFn ?? 106 + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 107 + 108 + const createStream = async function* () { 109 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 110 + let attempt = 0; 111 + const signal = options.signal ?? new AbortController().signal; 112 + 113 + while (true) { 114 + if (signal.aborted) break; 115 + 116 + attempt++; 117 + 118 + const headers = 119 + options.headers instanceof Headers 120 + ? options.headers 121 + : new Headers(options.headers as Record<string, string> | undefined); 122 + 123 + if (lastEventId !== undefined) { 124 + headers.set('Last-Event-ID', lastEventId); 125 + } 126 + 127 + try { 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 143 + 144 + if (!response.ok) 145 + throw new Error( 146 + `SSE failed: ${response.status} ${response.statusText}`, 147 + ); 148 + 149 + if (!response.body) throw new Error('No body in SSE response'); 150 + 151 + const reader = response.body 152 + .pipeThrough(new TextDecoderStream()) 153 + .getReader(); 154 + 155 + let buffer = ''; 156 + 157 + const abortHandler = () => { 158 + try { 159 + reader.cancel(); 160 + } catch { 161 + // noop 162 + } 163 + }; 164 + 165 + signal.addEventListener('abort', abortHandler); 166 + 167 + try { 168 + while (true) { 169 + const { done, value } = await reader.read(); 170 + if (done) break; 171 + buffer += value; 172 + 173 + const chunks = buffer.split('\n\n'); 174 + buffer = chunks.pop() ?? ''; 175 + 176 + for (const chunk of chunks) { 177 + const lines = chunk.split('\n'); 178 + const dataLines: Array<string> = []; 179 + let eventName: string | undefined; 180 + 181 + for (const line of lines) { 182 + if (line.startsWith('data:')) { 183 + dataLines.push(line.replace(/^data:\s*/, '')); 184 + } else if (line.startsWith('event:')) { 185 + eventName = line.replace(/^event:\s*/, ''); 186 + } else if (line.startsWith('id:')) { 187 + lastEventId = line.replace(/^id:\s*/, ''); 188 + } else if (line.startsWith('retry:')) { 189 + const parsed = Number.parseInt( 190 + line.replace(/^retry:\s*/, ''), 191 + 10, 192 + ); 193 + if (!Number.isNaN(parsed)) { 194 + retryDelay = parsed; 195 + } 196 + } 197 + } 198 + 199 + let data: unknown; 200 + let parsedJson = false; 201 + 202 + if (dataLines.length) { 203 + const rawData = dataLines.join('\n'); 204 + try { 205 + data = JSON.parse(rawData); 206 + parsedJson = true; 207 + } catch { 208 + data = rawData; 209 + } 210 + } 211 + 212 + if (parsedJson) { 213 + if (responseValidator) { 214 + await responseValidator(data); 215 + } 216 + 217 + if (responseTransformer) { 218 + data = await responseTransformer(data); 219 + } 220 + } 221 + 222 + onSseEvent?.({ 223 + data, 224 + event: eventName, 225 + id: lastEventId, 226 + retry: retryDelay, 227 + }); 228 + 229 + if (dataLines.length) { 230 + yield data as any; 231 + } 232 + } 233 + } 234 + } finally { 235 + signal.removeEventListener('abort', abortHandler); 236 + reader.releaseLock(); 237 + } 238 + 239 + break; // exit loop on normal completion 240 + } catch (error) { 241 + // connection failed or aborted; retry after delay 242 + onSseError?.(error); 243 + 244 + if ( 245 + sseMaxRetryAttempts !== undefined && 246 + attempt >= sseMaxRetryAttempts 247 + ) { 248 + break; // stop after firing error 249 + } 250 + 251 + // exponential backoff: double retry each attempt, cap at 30s 252 + const backoff = Math.min( 253 + retryDelay * 2 ** (attempt - 1), 254 + sseMaxRetryDelay ?? 30000, 255 + ); 256 + await sleep(backoff); 257 + } 258 + } 259 + }; 260 + 261 + const stream = createStream(); 262 + 263 + return { stream }; 264 + };
+118
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { 5 + BodySerializer, 6 + QuerySerializer, 7 + QuerySerializerOptions, 8 + } from './bodySerializer.gen'; 9 + 10 + export type HttpMethod = 11 + | 'connect' 12 + | 'delete' 13 + | 'get' 14 + | 'head' 15 + | 'options' 16 + | 'patch' 17 + | 'post' 18 + | 'put' 19 + | 'trace'; 20 + 21 + export type Client< 22 + RequestFn = never, 23 + Config = unknown, 24 + MethodFn = never, 25 + BuildUrlFn = never, 26 + SseFn = never, 27 + > = { 28 + /** 29 + * Returns the final request URL. 30 + */ 31 + buildUrl: BuildUrlFn; 32 + getConfig: () => Config; 33 + request: RequestFn; 34 + setConfig: (config: Config) => Config; 35 + } & { 36 + [K in HttpMethod]: MethodFn; 37 + } & ([SseFn] extends [never] 38 + ? { sse?: never } 39 + : { sse: { [K in HttpMethod]: SseFn } }); 40 + 41 + export interface Config { 42 + /** 43 + * Auth token or a function returning auth token. The resolved value will be 44 + * added to the request payload as defined by its `security` array. 45 + */ 46 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 47 + /** 48 + * A function for serializing request body parameter. By default, 49 + * {@link JSON.stringify()} will be used. 50 + */ 51 + bodySerializer?: BodySerializer | null; 52 + /** 53 + * An object containing any HTTP headers that you want to pre-populate your 54 + * `Headers` object with. 55 + * 56 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 57 + */ 58 + headers?: 59 + | RequestInit['headers'] 60 + | Record< 61 + string, 62 + | string 63 + | number 64 + | boolean 65 + | (string | number | boolean)[] 66 + | null 67 + | undefined 68 + | unknown 69 + >; 70 + /** 71 + * The request method. 72 + * 73 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 74 + */ 75 + method?: Uppercase<HttpMethod>; 76 + /** 77 + * A function for serializing request query parameters. By default, arrays 78 + * will be exploded in form style, objects will be exploded in deepObject 79 + * style, and reserved characters are percent-encoded. 80 + * 81 + * This method will have no effect if the native `paramsSerializer()` Axios 82 + * API function is used. 83 + * 84 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 85 + */ 86 + querySerializer?: QuerySerializer | QuerySerializerOptions; 87 + /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 94 + * A function transforming response data before it's returned. This is useful 95 + * for post-processing data, e.g. converting ISO strings into Date objects. 96 + */ 97 + responseTransformer?: (data: unknown) => Promise<unknown>; 98 + /** 99 + * A function validating response data. This is useful if you want to ensure 100 + * the response conforms to the desired shape, so it can be safely passed to 101 + * the transformers and returned to the user. 102 + */ 103 + responseValidator?: (data: unknown) => Promise<unknown>; 104 + } 105 + 106 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 107 + ? true 108 + : [T] extends [never | undefined] 109 + ? [undefined] extends [T] 110 + ? false 111 + : true 112 + : false; 113 + 114 + export type OmitNever<T extends Record<string, unknown>> = { 115 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true 116 + ? never 117 + : K]: T[K]; 118 + };
+114
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace( 48 + match, 49 + serializeArrayParam({ explode, name, style, value }), 50 + ); 51 + continue; 52 + } 53 + 54 + if (typeof value === 'object') { 55 + url = url.replace( 56 + match, 57 + serializeObjectParam({ 58 + explode, 59 + name, 60 + style, 61 + value: value as Record<string, unknown>, 62 + valueOnly: true, 63 + }), 64 + ); 65 + continue; 66 + } 67 + 68 + if (style === 'matrix') { 69 + url = url.replace( 70 + match, 71 + `;${serializePrimitiveParam({ 72 + name, 73 + value: value as string, 74 + })}`, 75 + ); 76 + continue; 77 + } 78 + 79 + const replaceValue = encodeURIComponent( 80 + style === 'label' ? `.${value as string}` : (value as string), 81 + ); 82 + url = url.replace(match, replaceValue); 83 + } 84 + } 85 + return url; 86 + }; 87 + 88 + export const getUrl = ({ 89 + baseUrl, 90 + path, 91 + query, 92 + querySerializer, 93 + url: _url, 94 + }: { 95 + baseUrl?: string; 96 + path?: Record<string, unknown>; 97 + query?: Record<string, unknown>; 98 + querySerializer: QuerySerializer; 99 + url: string; 100 + }) => { 101 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 102 + let url = (baseUrl ?? '') + pathUrl; 103 + if (path) { 104 + url = defaultPathSerializer({ path, url }); 105 + } 106 + let search = query ? querySerializer(query) : ''; 107 + if (search.startsWith('?')) { 108 + search = search.substring(1); 109 + } 110 + if (search) { 111 + url += `?${search}`; 112 + } 113 + return url; 114 + };
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './sdk.gen';
+409
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; 4 + 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'; 5 + import { client as _heyApiClient } from './client.gen'; 6 + 7 + export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => { 22 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 23 + url: '/api/v{api-version}/no+tag', 24 + ...options 25 + }); 26 + }; 27 + 28 + export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => { 29 + return (options?.client ?? _heyApiClient).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ 30 + url: '/api/v{api-version}/no+tag', 31 + ...options 32 + }); 33 + }; 34 + 35 + export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => { 36 + return (options.client ?? _heyApiClient).post<ImportResponses, unknown, ThrowOnError>({ 37 + url: '/api/v{api-version}/no+tag', 38 + ...options, 39 + headers: { 40 + 'Content-Type': 'application/json', 41 + ...options.headers 42 + } 43 + }); 44 + }; 45 + 46 + export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => { 47 + return (options?.client ?? _heyApiClient).put<FooWowResponses, unknown, ThrowOnError>({ 48 + url: '/api/v{api-version}/no+tag', 49 + ...options 50 + }); 51 + }; 52 + 53 + export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => { 54 + return (options?.client ?? _heyApiClient).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ 55 + url: '/api/v{api-version}/simple/$count', 56 + ...options 57 + }); 58 + }; 59 + 60 + export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => { 61 + return (options.client ?? _heyApiClient).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ 62 + url: '/api/v{api-version}/simple:operation', 63 + ...options 64 + }); 65 + }; 66 + 67 + export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => { 68 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 69 + url: '/api/v{api-version}/simple', 70 + ...options 71 + }); 72 + }; 73 + 74 + export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => { 75 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 76 + url: '/api/v{api-version}/simple', 77 + ...options 78 + }); 79 + }; 80 + 81 + export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => { 82 + return (options?.client ?? _heyApiClient).head<unknown, unknown, ThrowOnError>({ 83 + url: '/api/v{api-version}/simple', 84 + ...options 85 + }); 86 + }; 87 + 88 + export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => { 89 + return (options?.client ?? _heyApiClient).options<unknown, unknown, ThrowOnError>({ 90 + url: '/api/v{api-version}/simple', 91 + ...options 92 + }); 93 + }; 94 + 95 + export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => { 96 + return (options?.client ?? _heyApiClient).patch<unknown, unknown, ThrowOnError>({ 97 + url: '/api/v{api-version}/simple', 98 + ...options 99 + }); 100 + }; 101 + 102 + export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => { 103 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 104 + url: '/api/v{api-version}/simple', 105 + ...options 106 + }); 107 + }; 108 + 109 + export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => { 110 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 111 + url: '/api/v{api-version}/simple', 112 + ...options 113 + }); 114 + }; 115 + 116 + export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => { 117 + return (options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 118 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 119 + ...options 120 + }); 121 + }; 122 + 123 + export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => { 124 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 125 + url: '/api/v{api-version}/descriptions', 126 + ...options 127 + }); 128 + }; 129 + 130 + /** 131 + * @deprecated 132 + */ 133 + export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => { 134 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 135 + url: '/api/v{api-version}/parameters/deprecated', 136 + ...options 137 + }); 138 + }; 139 + 140 + export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => { 141 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 142 + url: '/api/v{api-version}/parameters/{parameterPath}', 143 + ...options, 144 + headers: { 145 + 'Content-Type': 'application/json', 146 + ...options.headers 147 + } 148 + }); 149 + }; 150 + 151 + export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 152 + return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 153 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 154 + ...options, 155 + headers: { 156 + 'Content-Type': 'application/json', 157 + ...options.headers 158 + } 159 + }); 160 + }; 161 + 162 + export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => { 163 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 164 + url: '/api/v{api-version}/parameters', 165 + ...options, 166 + headers: { 167 + 'Content-Type': 'application/json', 168 + ...options.headers 169 + } 170 + }); 171 + }; 172 + 173 + export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => { 174 + return (options.client ?? _heyApiClient).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 175 + url: '/api/v{api-version}/parameters', 176 + ...options, 177 + headers: { 178 + 'Content-Type': 'application/json', 179 + ...options.headers 180 + } 181 + }); 182 + }; 183 + 184 + export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => { 185 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 186 + url: '/api/v{api-version}/requestBody', 187 + ...options, 188 + headers: { 189 + 'Content-Type': 'application/json', 190 + ...options?.headers 191 + } 192 + }); 193 + }; 194 + 195 + export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => { 196 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 197 + ...formDataBodySerializer, 198 + url: '/api/v{api-version}/formData', 199 + ...options, 200 + headers: { 201 + 'Content-Type': null, 202 + ...options?.headers 203 + } 204 + }); 205 + }; 206 + 207 + export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => { 208 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 209 + url: '/api/v{api-version}/defaults', 210 + ...options 211 + }); 212 + }; 213 + 214 + export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => { 215 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 216 + url: '/api/v{api-version}/defaults', 217 + ...options 218 + }); 219 + }; 220 + 221 + export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => { 222 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 223 + url: '/api/v{api-version}/defaults', 224 + ...options 225 + }); 226 + }; 227 + 228 + export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => { 229 + return (options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({ 230 + url: '/api/v{api-version}/duplicate', 231 + ...options 232 + }); 233 + }; 234 + 235 + export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => { 236 + return (options?.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 237 + url: '/api/v{api-version}/duplicate', 238 + ...options 239 + }); 240 + }; 241 + 242 + export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => { 243 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 244 + url: '/api/v{api-version}/duplicate', 245 + ...options 246 + }); 247 + }; 248 + 249 + export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => { 250 + return (options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 251 + url: '/api/v{api-version}/duplicate', 252 + ...options 253 + }); 254 + }; 255 + 256 + export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => { 257 + return (options?.client ?? _heyApiClient).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ 258 + url: '/api/v{api-version}/no-content', 259 + ...options 260 + }); 261 + }; 262 + 263 + export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => { 264 + return (options?.client ?? _heyApiClient).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ 265 + url: '/api/v{api-version}/multiple-tags/response-and-no-content', 266 + ...options 267 + }); 268 + }; 269 + 270 + export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => { 271 + return (options?.client ?? _heyApiClient).get<DummyAResponses, unknown, ThrowOnError>({ 272 + url: '/api/v{api-version}/multiple-tags/a', 273 + ...options 274 + }); 275 + }; 276 + 277 + export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => { 278 + return (options?.client ?? _heyApiClient).get<DummyBResponses, unknown, ThrowOnError>({ 279 + url: '/api/v{api-version}/multiple-tags/b', 280 + ...options 281 + }); 282 + }; 283 + 284 + export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => { 285 + return (options?.client ?? _heyApiClient).get<CallWithResponseResponses, unknown, ThrowOnError>({ 286 + url: '/api/v{api-version}/response', 287 + ...options 288 + }); 289 + }; 290 + 291 + export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => { 292 + return (options?.client ?? _heyApiClient).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ 293 + url: '/api/v{api-version}/response', 294 + ...options 295 + }); 296 + }; 297 + 298 + export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => { 299 + return (options?.client ?? _heyApiClient).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ 300 + url: '/api/v{api-version}/response', 301 + ...options 302 + }); 303 + }; 304 + 305 + export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => { 306 + return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({ 307 + url: '/api/v{api-version}/collectionFormat', 308 + ...options 309 + }); 310 + }; 311 + 312 + export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => { 313 + return (options.client ?? _heyApiClient).get<TypesResponses, unknown, ThrowOnError>({ 314 + url: '/api/v{api-version}/types', 315 + ...options 316 + }); 317 + }; 318 + 319 + export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => { 320 + return (options.client ?? _heyApiClient).post<UploadFileResponses, unknown, ThrowOnError>({ 321 + ...urlSearchParamsBodySerializer, 322 + url: '/api/v{api-version}/upload', 323 + ...options, 324 + headers: { 325 + 'Content-Type': 'application/x-www-form-urlencoded', 326 + ...options.headers 327 + } 328 + }); 329 + }; 330 + 331 + export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => { 332 + return (options.client ?? _heyApiClient).get<FileResponseResponses, unknown, ThrowOnError>({ 333 + url: '/api/v{api-version}/file/{id}', 334 + ...options 335 + }); 336 + }; 337 + 338 + export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => { 339 + return (options.client ?? _heyApiClient).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 340 + url: '/api/v{api-version}/complex', 341 + ...options 342 + }); 343 + }; 344 + 345 + export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => { 346 + return (options?.client ?? _heyApiClient).get<MultipartResponseResponses, unknown, ThrowOnError>({ 347 + url: '/api/v{api-version}/multipart', 348 + ...options 349 + }); 350 + }; 351 + 352 + export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => { 353 + return (options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({ 354 + ...formDataBodySerializer, 355 + url: '/api/v{api-version}/multipart', 356 + ...options, 357 + headers: { 358 + 'Content-Type': null, 359 + ...options?.headers 360 + } 361 + }); 362 + }; 363 + 364 + export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => { 365 + return (options.client ?? _heyApiClient).put<ComplexParamsResponses, unknown, ThrowOnError>({ 366 + url: '/api/v{api-version}/complex/{id}', 367 + ...options, 368 + headers: { 369 + 'Content-Type': 'application/json-patch+json', 370 + ...options.headers 371 + } 372 + }); 373 + }; 374 + 375 + export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => { 376 + return (options?.client ?? _heyApiClient).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ 377 + url: '/api/v{api-version}/header', 378 + ...options 379 + }); 380 + }; 381 + 382 + export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => { 383 + return (options.client ?? _heyApiClient).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ 384 + url: '/api/v{api-version}/error', 385 + ...options 386 + }); 387 + }; 388 + 389 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => { 390 + return (options.client ?? _heyApiClient).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ 391 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 392 + ...options 393 + }); 394 + }; 395 + 396 + /** 397 + * Login User 398 + */ 399 + export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => { 400 + return (options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({ 401 + ...urlSearchParamsBodySerializer, 402 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 403 + ...options, 404 + headers: { 405 + 'Content-Type': 'application/x-www-form-urlencoded', 406 + ...options.headers 407 + } 408 + }); 409 + };
+2063
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * External ref to shared model (A) 10 + */ 11 + export type ExternalRefA = { 12 + id: string; 13 + name?: string; 14 + }; 15 + 16 + /** 17 + * External ref to shared model (B) 18 + */ 19 + export type ExternalRefB = ExternalRefA; 20 + 21 + /** 22 + * Testing multiline comments in string: First line 23 + * Second line 24 + * 25 + * Fourth line 26 + */ 27 + export type CamelCaseCommentWithBreaks = number; 28 + 29 + /** 30 + * Testing multiline comments in string: First line 31 + * Second line 32 + * 33 + * Fourth line 34 + */ 35 + export type CommentWithBreaks = number; 36 + 37 + /** 38 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 39 + */ 40 + export type CommentWithBackticks = number; 41 + 42 + /** 43 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 44 + */ 45 + export type CommentWithBackticksAndQuotes = number; 46 + 47 + /** 48 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 49 + */ 50 + export type CommentWithSlashes = number; 51 + 52 + /** 53 + * Testing expression placeholders in string: ${expression} should work 54 + */ 55 + export type CommentWithExpressionPlaceholders = number; 56 + 57 + /** 58 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 59 + */ 60 + export type CommentWithQuotes = number; 61 + 62 + /** 63 + * Testing reserved characters in string: * inline * and ** inline ** should work 64 + */ 65 + export type CommentWithReservedCharacters = number; 66 + 67 + /** 68 + * This is a simple number 69 + */ 70 + export type SimpleInteger = number; 71 + 72 + /** 73 + * This is a simple boolean 74 + */ 75 + export type SimpleBoolean = boolean; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export type SimpleString = string; 81 + 82 + /** 83 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 84 + */ 85 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 86 + 87 + /** 88 + * This is a simple file 89 + */ 90 + export type SimpleFile = Blob | File; 91 + 92 + /** 93 + * This is a simple reference 94 + */ 95 + export type SimpleReference = ModelWithString; 96 + 97 + /** 98 + * This is a simple string 99 + */ 100 + export type SimpleStringWithPattern = string | null; 101 + 102 + /** 103 + * This is a simple enum with strings 104 + */ 105 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 106 + 107 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 108 + 109 + /** 110 + * This is a simple enum with numbers 111 + */ 112 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 113 + 114 + /** 115 + * Success=1,Warning=2,Error=3 116 + */ 117 + export type EnumFromDescription = number; 118 + 119 + /** 120 + * This is a simple enum with numbers 121 + */ 122 + export type EnumWithExtensions = 200 | 400 | 500; 123 + 124 + export type EnumWithXEnumNames = 0 | 1 | 2; 125 + 126 + /** 127 + * This is a simple array with numbers 128 + */ 129 + export type ArrayWithNumbers = Array<number>; 130 + 131 + /** 132 + * This is a simple array with booleans 133 + */ 134 + export type ArrayWithBooleans = Array<boolean>; 135 + 136 + /** 137 + * This is a simple array with strings 138 + */ 139 + export type ArrayWithStrings = Array<string>; 140 + 141 + /** 142 + * This is a simple array with references 143 + */ 144 + export type ArrayWithReferences = Array<ModelWithString>; 145 + 146 + /** 147 + * This is a simple array containing an array 148 + */ 149 + export type ArrayWithArray = Array<Array<ModelWithString>>; 150 + 151 + /** 152 + * This is a simple array with properties 153 + */ 154 + export type ArrayWithProperties = Array<{ 155 + '16x16'?: CamelCaseCommentWithBreaks; 156 + bar?: string; 157 + }>; 158 + 159 + /** 160 + * This is a simple array with any of properties 161 + */ 162 + export type ArrayWithAnyOfProperties = Array<{ 163 + foo?: string; 164 + } | { 165 + bar?: string; 166 + }>; 167 + 168 + export type AnyOfAnyAndNull = { 169 + data?: unknown | null; 170 + }; 171 + 172 + /** 173 + * This is a simple array with any of properties 174 + */ 175 + export type AnyOfArrays = { 176 + results?: Array<{ 177 + foo?: string; 178 + } | { 179 + bar?: string; 180 + }>; 181 + }; 182 + 183 + /** 184 + * This is a string dictionary 185 + */ 186 + export type DictionaryWithString = { 187 + [key: string]: string; 188 + }; 189 + 190 + export type DictionaryWithPropertiesAndAdditionalProperties = { 191 + foo?: number; 192 + bar?: boolean; 193 + [key: string]: string | number | boolean | undefined; 194 + }; 195 + 196 + /** 197 + * This is a string reference 198 + */ 199 + export type DictionaryWithReference = { 200 + [key: string]: ModelWithString; 201 + }; 202 + 203 + /** 204 + * This is a complex dictionary 205 + */ 206 + export type DictionaryWithArray = { 207 + [key: string]: Array<ModelWithString>; 208 + }; 209 + 210 + /** 211 + * This is a string dictionary 212 + */ 213 + export type DictionaryWithDictionary = { 214 + [key: string]: { 215 + [key: string]: string; 216 + }; 217 + }; 218 + 219 + /** 220 + * This is a complex dictionary 221 + */ 222 + export type DictionaryWithProperties = { 223 + [key: string]: { 224 + foo?: string; 225 + bar?: string; 226 + }; 227 + }; 228 + 229 + /** 230 + * This is a model with one number property 231 + */ 232 + export type ModelWithInteger = { 233 + /** 234 + * This is a simple number property 235 + */ 236 + prop?: number; 237 + }; 238 + 239 + /** 240 + * This is a model with one boolean property 241 + */ 242 + export type ModelWithBoolean = { 243 + /** 244 + * This is a simple boolean property 245 + */ 246 + prop?: boolean; 247 + }; 248 + 249 + /** 250 + * This is a model with one string property 251 + */ 252 + export type ModelWithString = { 253 + /** 254 + * This is a simple string property 255 + */ 256 + prop?: string; 257 + }; 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export type ModelWithStringError = { 263 + /** 264 + * This is a simple string property 265 + */ 266 + prop?: string; 267 + }; 268 + 269 + /** 270 + * `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) 271 + */ 272 + export type ModelFromZendesk = string; 273 + 274 + /** 275 + * This is a model with one string property 276 + */ 277 + export type ModelWithNullableString = { 278 + /** 279 + * This is a simple string property 280 + */ 281 + nullableProp1?: string | null; 282 + /** 283 + * This is a simple string property 284 + */ 285 + nullableRequiredProp1: string | null; 286 + /** 287 + * This is a simple string property 288 + */ 289 + nullableProp2?: string | null; 290 + /** 291 + * This is a simple string property 292 + */ 293 + nullableRequiredProp2: string | null; 294 + /** 295 + * This is a simple enum with strings 296 + */ 297 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 298 + }; 299 + 300 + /** 301 + * This is a model with one enum 302 + */ 303 + export type ModelWithEnum = { 304 + /** 305 + * This is a simple enum with strings 306 + */ 307 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 308 + /** 309 + * These are the HTTP error code enums 310 + */ 311 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 312 + /** 313 + * Simple boolean enum 314 + */ 315 + bool?: true; 316 + }; 317 + 318 + /** 319 + * This is a model with one enum with escaped name 320 + */ 321 + export type ModelWithEnumWithHyphen = { 322 + /** 323 + * Foo-Bar-Baz-Qux 324 + */ 325 + 'foo-bar-baz-qux'?: '3.0'; 326 + }; 327 + 328 + /** 329 + * This is a model with one enum 330 + */ 331 + export type ModelWithEnumFromDescription = { 332 + /** 333 + * Success=1,Warning=2,Error=3 334 + */ 335 + test?: number; 336 + }; 337 + 338 + /** 339 + * This is a model with nested enums 340 + */ 341 + export type ModelWithNestedEnums = { 342 + dictionaryWithEnum?: { 343 + [key: string]: 'Success' | 'Warning' | 'Error'; 344 + }; 345 + dictionaryWithEnumFromDescription?: { 346 + [key: string]: number; 347 + }; 348 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 349 + arrayWithDescription?: Array<number>; 350 + /** 351 + * This is a simple enum with strings 352 + */ 353 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 354 + }; 355 + 356 + /** 357 + * This is a model with one property containing a reference 358 + */ 359 + export type ModelWithReference = { 360 + prop?: ModelWithProperties; 361 + }; 362 + 363 + /** 364 + * This is a model with one property containing an array 365 + */ 366 + export type ModelWithArrayReadOnlyAndWriteOnly = { 367 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 368 + propWithFile?: Array<Blob | File>; 369 + propWithNumber?: Array<number>; 370 + }; 371 + 372 + /** 373 + * This is a model with one property containing an array 374 + */ 375 + export type ModelWithArray = { 376 + prop?: Array<ModelWithString>; 377 + propWithFile?: Array<Blob | File>; 378 + propWithNumber?: Array<number>; 379 + }; 380 + 381 + /** 382 + * This is a model with one property containing a dictionary 383 + */ 384 + export type ModelWithDictionary = { 385 + prop?: { 386 + [key: string]: string; 387 + }; 388 + }; 389 + 390 + /** 391 + * This is a deprecated model with a deprecated property 392 + * @deprecated 393 + */ 394 + export type DeprecatedModel = { 395 + /** 396 + * This is a deprecated property 397 + * @deprecated 398 + */ 399 + prop?: string; 400 + }; 401 + 402 + /** 403 + * This is a model with one property containing a circular reference 404 + */ 405 + export type ModelWithCircularReference = { 406 + prop?: ModelWithCircularReference; 407 + }; 408 + 409 + /** 410 + * This is a model with one property with a 'one of' relationship 411 + */ 412 + export type CompositionWithOneOf = { 413 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 414 + }; 415 + 416 + /** 417 + * This is a model with one property with a 'one of' relationship where the options are not $ref 418 + */ 419 + export type CompositionWithOneOfAnonymous = { 420 + propA?: { 421 + propA?: string; 422 + } | string | number; 423 + }; 424 + 425 + /** 426 + * Circle 427 + */ 428 + export type ModelCircle = { 429 + kind: string; 430 + radius?: number; 431 + }; 432 + 433 + /** 434 + * Square 435 + */ 436 + export type ModelSquare = { 437 + kind: string; 438 + sideLength?: number; 439 + }; 440 + 441 + /** 442 + * This is a model with one property with a 'one of' relationship where the options are not $ref 443 + */ 444 + export type CompositionWithOneOfDiscriminator = ({ 445 + kind: 'circle'; 446 + } & ModelCircle) | ({ 447 + kind: 'square'; 448 + } & ModelSquare); 449 + 450 + /** 451 + * This is a model with one property with a 'any of' relationship 452 + */ 453 + export type CompositionWithAnyOf = { 454 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 455 + }; 456 + 457 + /** 458 + * This is a model with one property with a 'any of' relationship where the options are not $ref 459 + */ 460 + export type CompositionWithAnyOfAnonymous = { 461 + propA?: { 462 + propA?: string; 463 + } | string | number; 464 + }; 465 + 466 + /** 467 + * This is a model with nested 'any of' property with a type null 468 + */ 469 + export type CompositionWithNestedAnyAndTypeNull = { 470 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 471 + }; 472 + 473 + export type _3eNum1Период = 'Bird' | 'Dog'; 474 + 475 + export type ConstValue = 'ConstValue'; 476 + 477 + /** 478 + * This is a model with one property with a 'any of' relationship where the options are not $ref 479 + */ 480 + export type CompositionWithNestedAnyOfAndNull = { 481 + /** 482 + * Scopes 483 + */ 484 + propA?: Array<_3eNum1Период | ConstValue> | null; 485 + }; 486 + 487 + /** 488 + * This is a model with one property with a 'one of' relationship 489 + */ 490 + export type CompositionWithOneOfAndNullable = { 491 + propA?: { 492 + boolean?: boolean; 493 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 494 + }; 495 + 496 + /** 497 + * This is a model that contains a simple dictionary within composition 498 + */ 499 + export type CompositionWithOneOfAndSimpleDictionary = { 500 + propA?: boolean | { 501 + [key: string]: number; 502 + }; 503 + }; 504 + 505 + /** 506 + * This is a model that contains a dictionary of simple arrays within composition 507 + */ 508 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 509 + propA?: boolean | { 510 + [key: string]: Array<boolean>; 511 + }; 512 + }; 513 + 514 + /** 515 + * This is a model that contains a dictionary of complex arrays (composited) within composition 516 + */ 517 + export type CompositionWithOneOfAndComplexArrayDictionary = { 518 + propA?: boolean | { 519 + [key: string]: Array<number | string>; 520 + }; 521 + }; 522 + 523 + /** 524 + * This is a model with one property with a 'all of' relationship 525 + */ 526 + export type CompositionWithAllOfAndNullable = { 527 + propA?: ({ 528 + boolean?: boolean; 529 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 530 + }; 531 + 532 + /** 533 + * This is a model with one property with a 'any of' relationship 534 + */ 535 + export type CompositionWithAnyOfAndNullable = { 536 + propA?: { 537 + boolean?: boolean; 538 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 539 + }; 540 + 541 + /** 542 + * This is a base model with two simple optional properties 543 + */ 544 + export type CompositionBaseModel = { 545 + firstName?: string; 546 + lastname?: string; 547 + }; 548 + 549 + /** 550 + * This is a model that extends the base model 551 + */ 552 + export type CompositionExtendedModel = CompositionBaseModel & { 553 + age: number; 554 + firstName: string; 555 + lastname: string; 556 + }; 557 + 558 + /** 559 + * This is a model with one nested property 560 + */ 561 + export type ModelWithProperties = { 562 + required: string; 563 + readonly requiredAndReadOnly: string; 564 + requiredAndNullable: string | null; 565 + string?: string; 566 + number?: number; 567 + boolean?: boolean; 568 + reference?: ModelWithString; 569 + 'property with space'?: string; 570 + default?: string; 571 + try?: string; 572 + readonly '@namespace.string'?: string; 573 + readonly '@namespace.integer'?: number; 574 + }; 575 + 576 + /** 577 + * This is a model with one nested property 578 + */ 579 + export type ModelWithNestedProperties = { 580 + readonly first: { 581 + readonly second: { 582 + readonly third: string | null; 583 + } | null; 584 + } | null; 585 + }; 586 + 587 + /** 588 + * This is a model with duplicated properties 589 + */ 590 + export type ModelWithDuplicateProperties = { 591 + prop?: ModelWithString; 592 + }; 593 + 594 + /** 595 + * This is a model with ordered properties 596 + */ 597 + export type ModelWithOrderedProperties = { 598 + zebra?: string; 599 + apple?: string; 600 + hawaii?: string; 601 + }; 602 + 603 + /** 604 + * This is a model with duplicated imports 605 + */ 606 + export type ModelWithDuplicateImports = { 607 + propA?: ModelWithString; 608 + propB?: ModelWithString; 609 + propC?: ModelWithString; 610 + }; 611 + 612 + /** 613 + * This is a model that extends another model 614 + */ 615 + export type ModelThatExtends = ModelWithString & { 616 + propExtendsA?: string; 617 + propExtendsB?: ModelWithString; 618 + }; 619 + 620 + /** 621 + * This is a model that extends another model 622 + */ 623 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 624 + propExtendsC?: string; 625 + propExtendsD?: ModelWithString; 626 + }; 627 + 628 + /** 629 + * This is a model that contains a some patterns 630 + */ 631 + export type ModelWithPattern = { 632 + key: string; 633 + name: string; 634 + readonly enabled?: boolean; 635 + readonly modified?: string; 636 + id?: string; 637 + text?: string; 638 + patternWithSingleQuotes?: string; 639 + patternWithNewline?: string; 640 + patternWithBacktick?: string; 641 + }; 642 + 643 + export type File = { 644 + /** 645 + * Id 646 + */ 647 + readonly id?: string; 648 + /** 649 + * Updated at 650 + */ 651 + readonly updated_at?: string; 652 + /** 653 + * Created at 654 + */ 655 + readonly created_at?: string; 656 + /** 657 + * Mime 658 + */ 659 + mime: string; 660 + /** 661 + * File 662 + */ 663 + readonly file?: string; 664 + }; 665 + 666 + export type Default = { 667 + name?: string; 668 + }; 669 + 670 + export type Pageable = { 671 + page?: number; 672 + size?: number; 673 + sort?: Array<string>; 674 + }; 675 + 676 + /** 677 + * This is a free-form object without additionalProperties. 678 + */ 679 + export type FreeFormObjectWithoutAdditionalProperties = { 680 + [key: string]: unknown; 681 + }; 682 + 683 + /** 684 + * This is a free-form object with additionalProperties: true. 685 + */ 686 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 687 + [key: string]: unknown; 688 + }; 689 + 690 + /** 691 + * This is a free-form object with additionalProperties: {}. 692 + */ 693 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 694 + [key: string]: unknown; 695 + }; 696 + 697 + export type ModelWithConst = { 698 + String?: 'String'; 699 + number?: 0; 700 + null?: null; 701 + withType?: 'Some string'; 702 + }; 703 + 704 + /** 705 + * This is a model with one property and additionalProperties: true 706 + */ 707 + export type ModelWithAdditionalPropertiesEqTrue = { 708 + /** 709 + * This is a simple string property 710 + */ 711 + prop?: string; 712 + [key: string]: unknown | string | undefined; 713 + }; 714 + 715 + export type NestedAnyOfArraysNullable = { 716 + nullableArray?: Array<string | boolean> | null; 717 + }; 718 + 719 + export type CompositionWithOneOfAndProperties = ({ 720 + foo: SimpleParameter; 721 + } | { 722 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 723 + }) & { 724 + baz: number | null; 725 + qux: number; 726 + }; 727 + 728 + /** 729 + * An object that can be null 730 + */ 731 + export type NullableObject = { 732 + foo?: string; 733 + } | null; 734 + 735 + /** 736 + * Some % character 737 + */ 738 + export type CharactersInDescription = string; 739 + 740 + export type ModelWithNullableObject = { 741 + data?: NullableObject; 742 + }; 743 + 744 + export type ModelWithOneOfEnum = { 745 + foo: 'Bar'; 746 + } | { 747 + foo: 'Baz'; 748 + } | { 749 + foo: 'Qux'; 750 + } | { 751 + content: string; 752 + foo: 'Quux'; 753 + } | { 754 + content: [ 755 + string, 756 + string 757 + ]; 758 + foo: 'Corge'; 759 + }; 760 + 761 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 762 + 763 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 764 + 765 + export type ModelWithNestedArrayEnumsData = { 766 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 767 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 768 + }; 769 + 770 + export type ModelWithNestedArrayEnums = { 771 + array_strings?: Array<string>; 772 + data?: ModelWithNestedArrayEnumsData; 773 + }; 774 + 775 + export type ModelWithNestedCompositionEnums = { 776 + foo?: ModelWithNestedArrayEnumsDataFoo; 777 + }; 778 + 779 + export type ModelWithReadOnlyAndWriteOnly = { 780 + foo: string; 781 + readonly bar: string; 782 + }; 783 + 784 + export type ModelWithConstantSizeArray = [ 785 + number, 786 + number 787 + ]; 788 + 789 + export type ModelWithAnyOfConstantSizeArray = [ 790 + number | string, 791 + number | string, 792 + number | string 793 + ]; 794 + 795 + export type ModelWithPrefixItemsConstantSizeArray = [ 796 + ModelWithInteger, 797 + number | string, 798 + string 799 + ]; 800 + 801 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 802 + number | null | string, 803 + number | null | string, 804 + number | null | string 805 + ]; 806 + 807 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 808 + number | Import, 809 + number | Import 810 + ]; 811 + 812 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 813 + number & string, 814 + number & string 815 + ]; 816 + 817 + export type ModelWithNumericEnumUnion = { 818 + /** 819 + * Период 820 + */ 821 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 822 + }; 823 + 824 + /** 825 + * Some description with `back ticks` 826 + */ 827 + export type ModelWithBackticksInDescription = { 828 + /** 829 + * The template `that` should be used for parsing and importing the contents of the CSV file. 830 + * 831 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 832 + * <pre> 833 + * [ 834 + * { 835 + * "resourceType": "Asset", 836 + * "identifier": { 837 + * "name": "${1}", 838 + * "domain": { 839 + * "name": "${2}", 840 + * "community": { 841 + * "name": "Some Community" 842 + * } 843 + * } 844 + * }, 845 + * "attributes" : { 846 + * "00000000-0000-0000-0000-000000003115" : [ { 847 + * "value" : "${3}" 848 + * } ], 849 + * "00000000-0000-0000-0000-000000000222" : [ { 850 + * "value" : "${4}" 851 + * } ] 852 + * } 853 + * } 854 + * ] 855 + * </pre> 856 + */ 857 + template?: string; 858 + }; 859 + 860 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 861 + baz: number | null; 862 + qux: number; 863 + }; 864 + 865 + /** 866 + * Model used to test deduplication strategy (unused) 867 + */ 868 + export type ParameterSimpleParameterUnused = string; 869 + 870 + /** 871 + * Model used to test deduplication strategy 872 + */ 873 + export type PostServiceWithEmptyTagResponse = string; 874 + 875 + /** 876 + * Model used to test deduplication strategy 877 + */ 878 + export type PostServiceWithEmptyTagResponse2 = string; 879 + 880 + /** 881 + * Model used to test deduplication strategy 882 + */ 883 + export type DeleteFooData = string; 884 + 885 + /** 886 + * Model used to test deduplication strategy 887 + */ 888 + export type DeleteFooData2 = string; 889 + 890 + /** 891 + * Model with restricted keyword name 892 + */ 893 + export type Import = string; 894 + 895 + export type SchemaWithFormRestrictedKeys = { 896 + description?: string; 897 + 'x-enum-descriptions'?: string; 898 + 'x-enum-varnames'?: string; 899 + 'x-enumNames'?: string; 900 + title?: string; 901 + object?: { 902 + description?: string; 903 + 'x-enum-descriptions'?: string; 904 + 'x-enum-varnames'?: string; 905 + 'x-enumNames'?: string; 906 + title?: string; 907 + }; 908 + array?: Array<{ 909 + description?: string; 910 + 'x-enum-descriptions'?: string; 911 + 'x-enum-varnames'?: string; 912 + 'x-enumNames'?: string; 913 + title?: string; 914 + }>; 915 + }; 916 + 917 + /** 918 + * This schema was giving PascalCase transformations a hard time 919 + */ 920 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 921 + /** 922 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 923 + */ 924 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 925 + }; 926 + 927 + /** 928 + * This schema was giving PascalCase transformations a hard time 929 + */ 930 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 931 + /** 932 + * Specifies the target ResourceVersion 933 + */ 934 + resourceVersion?: string; 935 + /** 936 + * Specifies the target UID. 937 + */ 938 + uid?: string; 939 + }; 940 + 941 + export type AdditionalPropertiesUnknownIssue = { 942 + [key: string]: string | number; 943 + }; 944 + 945 + export type AdditionalPropertiesUnknownIssue2 = { 946 + [key: string]: string | number; 947 + }; 948 + 949 + export type AdditionalPropertiesUnknownIssue3 = string & { 950 + entries: { 951 + [key: string]: AdditionalPropertiesUnknownIssue; 952 + }; 953 + }; 954 + 955 + export type AdditionalPropertiesIntegerIssue = { 956 + value: number; 957 + [key: string]: number; 958 + }; 959 + 960 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 961 + 962 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 963 + item?: boolean; 964 + error?: string | null; 965 + readonly hasError?: boolean; 966 + data?: { 967 + [key: string]: never; 968 + }; 969 + }; 970 + 971 + export type GenericSchemaDuplicateIssue1SystemString = { 972 + item?: string | null; 973 + error?: string | null; 974 + readonly hasError?: boolean; 975 + }; 976 + 977 + /** 978 + * This is a model with one nested property 979 + */ 980 + export type ModelWithPropertiesWritable = { 981 + required: string; 982 + requiredAndNullable: string | null; 983 + string?: string; 984 + number?: number; 985 + boolean?: boolean; 986 + reference?: ModelWithString; 987 + 'property with space'?: string; 988 + default?: string; 989 + try?: string; 990 + }; 991 + 992 + /** 993 + * This is a model that contains a some patterns 994 + */ 995 + export type ModelWithPatternWritable = { 996 + key: string; 997 + name: string; 998 + id?: string; 999 + text?: string; 1000 + patternWithSingleQuotes?: string; 1001 + patternWithNewline?: string; 1002 + patternWithBacktick?: string; 1003 + }; 1004 + 1005 + export type FileWritable = { 1006 + /** 1007 + * Mime 1008 + */ 1009 + mime: string; 1010 + }; 1011 + 1012 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1013 + foo: string; 1014 + baz: string; 1015 + }; 1016 + 1017 + export type AdditionalPropertiesUnknownIssueWritable = { 1018 + [key: string]: string | number; 1019 + }; 1020 + 1021 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1022 + item?: boolean; 1023 + error?: string | null; 1024 + data?: { 1025 + [key: string]: never; 1026 + }; 1027 + }; 1028 + 1029 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1030 + item?: string | null; 1031 + error?: string | null; 1032 + }; 1033 + 1034 + /** 1035 + * This is a reusable parameter 1036 + */ 1037 + export type SimpleParameter = string; 1038 + 1039 + /** 1040 + * Parameter with illegal characters 1041 + */ 1042 + export type XFooBar = ModelWithString; 1043 + 1044 + /** 1045 + * A reusable request body 1046 + */ 1047 + export type SimpleRequestBody = ModelWithString; 1048 + 1049 + /** 1050 + * A reusable request body 1051 + */ 1052 + export type SimpleFormData = ModelWithString; 1053 + 1054 + export type ExportData = { 1055 + body?: never; 1056 + path?: never; 1057 + query?: never; 1058 + url: '/api/v{api-version}/no+tag'; 1059 + }; 1060 + 1061 + export type PatchApiVbyApiVersionNoTagData = { 1062 + body?: never; 1063 + path?: never; 1064 + query?: never; 1065 + url: '/api/v{api-version}/no+tag'; 1066 + }; 1067 + 1068 + export type PatchApiVbyApiVersionNoTagResponses = { 1069 + /** 1070 + * OK 1071 + */ 1072 + default: unknown; 1073 + }; 1074 + 1075 + export type ImportData = { 1076 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; 1077 + path?: never; 1078 + query?: never; 1079 + url: '/api/v{api-version}/no+tag'; 1080 + }; 1081 + 1082 + export type ImportResponses = { 1083 + /** 1084 + * Success 1085 + */ 1086 + 200: ModelFromZendesk; 1087 + /** 1088 + * Default success response 1089 + */ 1090 + default: ModelWithReadOnlyAndWriteOnly; 1091 + }; 1092 + 1093 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1094 + 1095 + export type FooWowData = { 1096 + body?: never; 1097 + path?: never; 1098 + query?: never; 1099 + url: '/api/v{api-version}/no+tag'; 1100 + }; 1101 + 1102 + export type FooWowResponses = { 1103 + /** 1104 + * OK 1105 + */ 1106 + default: unknown; 1107 + }; 1108 + 1109 + export type ApiVVersionODataControllerCountData = { 1110 + body?: never; 1111 + path?: never; 1112 + query?: never; 1113 + url: '/api/v{api-version}/simple/$count'; 1114 + }; 1115 + 1116 + export type ApiVVersionODataControllerCountResponses = { 1117 + /** 1118 + * Success 1119 + */ 1120 + 200: ModelFromZendesk; 1121 + }; 1122 + 1123 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1124 + 1125 + export type GetApiVbyApiVersionSimpleOperationData = { 1126 + body?: never; 1127 + path: { 1128 + /** 1129 + * foo in method 1130 + */ 1131 + foo_param: string; 1132 + }; 1133 + query?: never; 1134 + url: '/api/v{api-version}/simple:operation'; 1135 + }; 1136 + 1137 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1138 + /** 1139 + * Default error response 1140 + */ 1141 + default: ModelWithBoolean; 1142 + }; 1143 + 1144 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1145 + 1146 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1147 + /** 1148 + * Response is a simple number 1149 + */ 1150 + 200: number; 1151 + }; 1152 + 1153 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1154 + 1155 + export type DeleteCallWithoutParametersAndResponseData = { 1156 + body?: never; 1157 + path?: never; 1158 + query?: never; 1159 + url: '/api/v{api-version}/simple'; 1160 + }; 1161 + 1162 + export type GetCallWithoutParametersAndResponseData = { 1163 + body?: never; 1164 + path?: never; 1165 + query?: never; 1166 + url: '/api/v{api-version}/simple'; 1167 + }; 1168 + 1169 + export type HeadCallWithoutParametersAndResponseData = { 1170 + body?: never; 1171 + path?: never; 1172 + query?: never; 1173 + url: '/api/v{api-version}/simple'; 1174 + }; 1175 + 1176 + export type OptionsCallWithoutParametersAndResponseData = { 1177 + body?: never; 1178 + path?: never; 1179 + query?: never; 1180 + url: '/api/v{api-version}/simple'; 1181 + }; 1182 + 1183 + export type PatchCallWithoutParametersAndResponseData = { 1184 + body?: never; 1185 + path?: never; 1186 + query?: never; 1187 + url: '/api/v{api-version}/simple'; 1188 + }; 1189 + 1190 + export type PostCallWithoutParametersAndResponseData = { 1191 + body?: never; 1192 + path?: never; 1193 + query?: never; 1194 + url: '/api/v{api-version}/simple'; 1195 + }; 1196 + 1197 + export type PutCallWithoutParametersAndResponseData = { 1198 + body?: never; 1199 + path?: never; 1200 + query?: never; 1201 + url: '/api/v{api-version}/simple'; 1202 + }; 1203 + 1204 + export type DeleteFooData3 = { 1205 + body?: never; 1206 + headers: { 1207 + /** 1208 + * Parameter with illegal characters 1209 + */ 1210 + 'x-Foo-Bar': ModelWithString; 1211 + }; 1212 + path: { 1213 + /** 1214 + * foo in method 1215 + */ 1216 + foo_param: string; 1217 + /** 1218 + * bar in method 1219 + */ 1220 + BarParam: string; 1221 + }; 1222 + query?: never; 1223 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1224 + }; 1225 + 1226 + export type CallWithDescriptionsData = { 1227 + body?: never; 1228 + path?: never; 1229 + query?: { 1230 + /** 1231 + * Testing multiline comments in string: First line 1232 + * Second line 1233 + * 1234 + * Fourth line 1235 + */ 1236 + parameterWithBreaks?: string; 1237 + /** 1238 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1239 + */ 1240 + parameterWithBackticks?: string; 1241 + /** 1242 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1243 + */ 1244 + parameterWithSlashes?: string; 1245 + /** 1246 + * Testing expression placeholders in string: ${expression} should work 1247 + */ 1248 + parameterWithExpressionPlaceholders?: string; 1249 + /** 1250 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1251 + */ 1252 + parameterWithQuotes?: string; 1253 + /** 1254 + * Testing reserved characters in string: * inline * and ** inline ** should work 1255 + */ 1256 + parameterWithReservedCharacters?: string; 1257 + }; 1258 + url: '/api/v{api-version}/descriptions'; 1259 + }; 1260 + 1261 + export type DeprecatedCallData = { 1262 + body?: never; 1263 + headers: { 1264 + /** 1265 + * This parameter is deprecated 1266 + * @deprecated 1267 + */ 1268 + parameter: DeprecatedModel | null; 1269 + }; 1270 + path?: never; 1271 + query?: never; 1272 + url: '/api/v{api-version}/parameters/deprecated'; 1273 + }; 1274 + 1275 + export type CallWithParametersData = { 1276 + /** 1277 + * This is the parameter that goes into the body 1278 + */ 1279 + body: { 1280 + [key: string]: unknown; 1281 + } | null; 1282 + headers: { 1283 + /** 1284 + * This is the parameter that goes into the header 1285 + */ 1286 + parameterHeader: string | null; 1287 + }; 1288 + path: { 1289 + /** 1290 + * This is the parameter that goes into the path 1291 + */ 1292 + parameterPath: string | null; 1293 + /** 1294 + * api-version should be required in standalone clients 1295 + */ 1296 + 'api-version': string | null; 1297 + }; 1298 + query: { 1299 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1300 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1301 + /** 1302 + * This is the parameter that goes into the query params 1303 + */ 1304 + cursor: string | null; 1305 + }; 1306 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1307 + }; 1308 + 1309 + export type CallWithWeirdParameterNamesData = { 1310 + /** 1311 + * This is the parameter that goes into the body 1312 + */ 1313 + body: ModelWithString | null; 1314 + headers: { 1315 + /** 1316 + * This is the parameter that goes into the request header 1317 + */ 1318 + 'parameter.header': string | null; 1319 + }; 1320 + path: { 1321 + /** 1322 + * This is the parameter that goes into the path 1323 + */ 1324 + 'parameter.path.1'?: string; 1325 + /** 1326 + * This is the parameter that goes into the path 1327 + */ 1328 + 'parameter-path-2'?: string; 1329 + /** 1330 + * This is the parameter that goes into the path 1331 + */ 1332 + 'PARAMETER-PATH-3'?: string; 1333 + /** 1334 + * api-version should be required in standalone clients 1335 + */ 1336 + 'api-version': string | null; 1337 + }; 1338 + query: { 1339 + /** 1340 + * This is the parameter with a reserved keyword 1341 + */ 1342 + default?: string; 1343 + /** 1344 + * This is the parameter that goes into the request query params 1345 + */ 1346 + 'parameter-query': string | null; 1347 + }; 1348 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1349 + }; 1350 + 1351 + export type GetCallWithOptionalParamData = { 1352 + /** 1353 + * This is a required parameter 1354 + */ 1355 + body: ModelWithOneOfEnum; 1356 + path?: never; 1357 + query?: { 1358 + /** 1359 + * This is an optional parameter 1360 + */ 1361 + page?: number; 1362 + }; 1363 + url: '/api/v{api-version}/parameters'; 1364 + }; 1365 + 1366 + export type PostCallWithOptionalParamData = { 1367 + /** 1368 + * This is an optional parameter 1369 + */ 1370 + body?: { 1371 + offset?: number | null; 1372 + }; 1373 + path?: never; 1374 + query: { 1375 + /** 1376 + * This is a required parameter 1377 + */ 1378 + parameter: Pageable; 1379 + }; 1380 + url: '/api/v{api-version}/parameters'; 1381 + }; 1382 + 1383 + export type PostCallWithOptionalParamResponses = { 1384 + /** 1385 + * Response is a simple number 1386 + */ 1387 + 200: number; 1388 + /** 1389 + * Success 1390 + */ 1391 + 204: void; 1392 + }; 1393 + 1394 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1395 + 1396 + export type PostApiVbyApiVersionRequestBodyData = { 1397 + /** 1398 + * A reusable request body 1399 + */ 1400 + body?: SimpleRequestBody; 1401 + path?: never; 1402 + query?: { 1403 + /** 1404 + * This is a reusable parameter 1405 + */ 1406 + parameter?: string; 1407 + }; 1408 + url: '/api/v{api-version}/requestBody'; 1409 + }; 1410 + 1411 + export type PostApiVbyApiVersionFormDataData = { 1412 + /** 1413 + * A reusable request body 1414 + */ 1415 + body?: SimpleFormData; 1416 + path?: never; 1417 + query?: { 1418 + /** 1419 + * This is a reusable parameter 1420 + */ 1421 + parameter?: string; 1422 + }; 1423 + url: '/api/v{api-version}/formData'; 1424 + }; 1425 + 1426 + export type CallWithDefaultParametersData = { 1427 + body?: never; 1428 + path?: never; 1429 + query?: { 1430 + /** 1431 + * This is a simple string with default value 1432 + */ 1433 + parameterString?: string | null; 1434 + /** 1435 + * This is a simple number with default value 1436 + */ 1437 + parameterNumber?: number | null; 1438 + /** 1439 + * This is a simple boolean with default value 1440 + */ 1441 + parameterBoolean?: boolean | null; 1442 + /** 1443 + * This is a simple enum with default value 1444 + */ 1445 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1446 + /** 1447 + * This is a simple model with default value 1448 + */ 1449 + parameterModel?: ModelWithString | null; 1450 + }; 1451 + url: '/api/v{api-version}/defaults'; 1452 + }; 1453 + 1454 + export type CallWithDefaultOptionalParametersData = { 1455 + body?: never; 1456 + path?: never; 1457 + query?: { 1458 + /** 1459 + * This is a simple string that is optional with default value 1460 + */ 1461 + parameterString?: string; 1462 + /** 1463 + * This is a simple number that is optional with default value 1464 + */ 1465 + parameterNumber?: number; 1466 + /** 1467 + * This is a simple boolean that is optional with default value 1468 + */ 1469 + parameterBoolean?: boolean; 1470 + /** 1471 + * This is a simple enum that is optional with default value 1472 + */ 1473 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1474 + /** 1475 + * This is a simple model that is optional with default value 1476 + */ 1477 + parameterModel?: ModelWithString; 1478 + }; 1479 + url: '/api/v{api-version}/defaults'; 1480 + }; 1481 + 1482 + export type CallToTestOrderOfParamsData = { 1483 + body?: never; 1484 + path?: never; 1485 + query: { 1486 + /** 1487 + * This is a optional string with default 1488 + */ 1489 + parameterOptionalStringWithDefault?: string; 1490 + /** 1491 + * This is a optional string with empty default 1492 + */ 1493 + parameterOptionalStringWithEmptyDefault?: string; 1494 + /** 1495 + * This is a optional string with no default 1496 + */ 1497 + parameterOptionalStringWithNoDefault?: string; 1498 + /** 1499 + * This is a string with default 1500 + */ 1501 + parameterStringWithDefault: string; 1502 + /** 1503 + * This is a string with empty default 1504 + */ 1505 + parameterStringWithEmptyDefault: string; 1506 + /** 1507 + * This is a string with no default 1508 + */ 1509 + parameterStringWithNoDefault: string; 1510 + /** 1511 + * This is a string that can be null with no default 1512 + */ 1513 + parameterStringNullableWithNoDefault?: string | null; 1514 + /** 1515 + * This is a string that can be null with default 1516 + */ 1517 + parameterStringNullableWithDefault?: string | null; 1518 + }; 1519 + url: '/api/v{api-version}/defaults'; 1520 + }; 1521 + 1522 + export type DuplicateNameData = { 1523 + body?: never; 1524 + path?: never; 1525 + query?: never; 1526 + url: '/api/v{api-version}/duplicate'; 1527 + }; 1528 + 1529 + export type DuplicateName2Data = { 1530 + body?: never; 1531 + path?: never; 1532 + query?: never; 1533 + url: '/api/v{api-version}/duplicate'; 1534 + }; 1535 + 1536 + export type DuplicateName3Data = { 1537 + body?: never; 1538 + path?: never; 1539 + query?: never; 1540 + url: '/api/v{api-version}/duplicate'; 1541 + }; 1542 + 1543 + export type DuplicateName4Data = { 1544 + body?: never; 1545 + path?: never; 1546 + query?: never; 1547 + url: '/api/v{api-version}/duplicate'; 1548 + }; 1549 + 1550 + export type CallWithNoContentResponseData = { 1551 + body?: never; 1552 + path?: never; 1553 + query?: never; 1554 + url: '/api/v{api-version}/no-content'; 1555 + }; 1556 + 1557 + export type CallWithNoContentResponseResponses = { 1558 + /** 1559 + * Success 1560 + */ 1561 + 204: void; 1562 + }; 1563 + 1564 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1565 + 1566 + export type CallWithResponseAndNoContentResponseData = { 1567 + body?: never; 1568 + path?: never; 1569 + query?: never; 1570 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1571 + }; 1572 + 1573 + export type CallWithResponseAndNoContentResponseResponses = { 1574 + /** 1575 + * Response is a simple number 1576 + */ 1577 + 200: number; 1578 + /** 1579 + * Success 1580 + */ 1581 + 204: void; 1582 + }; 1583 + 1584 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1585 + 1586 + export type DummyAData = { 1587 + body?: never; 1588 + path?: never; 1589 + query?: never; 1590 + url: '/api/v{api-version}/multiple-tags/a'; 1591 + }; 1592 + 1593 + export type DummyAResponses = { 1594 + 200: _400; 1595 + }; 1596 + 1597 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1598 + 1599 + export type DummyBData = { 1600 + body?: never; 1601 + path?: never; 1602 + query?: never; 1603 + url: '/api/v{api-version}/multiple-tags/b'; 1604 + }; 1605 + 1606 + export type DummyBResponses = { 1607 + /** 1608 + * Success 1609 + */ 1610 + 204: void; 1611 + }; 1612 + 1613 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1614 + 1615 + export type CallWithResponseData = { 1616 + body?: never; 1617 + path?: never; 1618 + query?: never; 1619 + url: '/api/v{api-version}/response'; 1620 + }; 1621 + 1622 + export type CallWithResponseResponses = { 1623 + default: Import; 1624 + }; 1625 + 1626 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1627 + 1628 + export type CallWithDuplicateResponsesData = { 1629 + body?: never; 1630 + path?: never; 1631 + query?: never; 1632 + url: '/api/v{api-version}/response'; 1633 + }; 1634 + 1635 + export type CallWithDuplicateResponsesErrors = { 1636 + /** 1637 + * Message for 500 error 1638 + */ 1639 + 500: ModelWithStringError; 1640 + /** 1641 + * Message for 501 error 1642 + */ 1643 + 501: ModelWithStringError; 1644 + /** 1645 + * Message for 502 error 1646 + */ 1647 + 502: ModelWithStringError; 1648 + /** 1649 + * Message for 4XX errors 1650 + */ 1651 + '4XX': DictionaryWithArray; 1652 + /** 1653 + * Default error response 1654 + */ 1655 + default: ModelWithBoolean; 1656 + }; 1657 + 1658 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1659 + 1660 + export type CallWithDuplicateResponsesResponses = { 1661 + /** 1662 + * Message for 200 response 1663 + */ 1664 + 200: ModelWithBoolean & ModelWithInteger; 1665 + /** 1666 + * Message for 201 response 1667 + */ 1668 + 201: ModelWithString; 1669 + /** 1670 + * Message for 202 response 1671 + */ 1672 + 202: ModelWithString; 1673 + }; 1674 + 1675 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1676 + 1677 + export type CallWithResponsesData = { 1678 + body?: never; 1679 + path?: never; 1680 + query?: never; 1681 + url: '/api/v{api-version}/response'; 1682 + }; 1683 + 1684 + export type CallWithResponsesErrors = { 1685 + /** 1686 + * Message for 500 error 1687 + */ 1688 + 500: ModelWithStringError; 1689 + /** 1690 + * Message for 501 error 1691 + */ 1692 + 501: ModelWithStringError; 1693 + /** 1694 + * Message for 502 error 1695 + */ 1696 + 502: ModelWithStringError; 1697 + /** 1698 + * Message for default response 1699 + */ 1700 + default: ModelWithStringError; 1701 + }; 1702 + 1703 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1704 + 1705 + export type CallWithResponsesResponses = { 1706 + /** 1707 + * Message for 200 response 1708 + */ 1709 + 200: { 1710 + readonly '@namespace.string'?: string; 1711 + readonly '@namespace.integer'?: number; 1712 + readonly value?: Array<ModelWithString>; 1713 + }; 1714 + /** 1715 + * Message for 201 response 1716 + */ 1717 + 201: ModelThatExtends; 1718 + /** 1719 + * Message for 202 response 1720 + */ 1721 + 202: ModelThatExtendsExtends; 1722 + }; 1723 + 1724 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1725 + 1726 + export type CollectionFormatData = { 1727 + body?: never; 1728 + path?: never; 1729 + query: { 1730 + /** 1731 + * This is an array parameter that is sent as csv format (comma-separated values) 1732 + */ 1733 + parameterArrayCSV: Array<string> | null; 1734 + /** 1735 + * This is an array parameter that is sent as ssv format (space-separated values) 1736 + */ 1737 + parameterArraySSV: Array<string> | null; 1738 + /** 1739 + * This is an array parameter that is sent as tsv format (tab-separated values) 1740 + */ 1741 + parameterArrayTSV: Array<string> | null; 1742 + /** 1743 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1744 + */ 1745 + parameterArrayPipes: Array<string> | null; 1746 + /** 1747 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1748 + */ 1749 + parameterArrayMulti: Array<string> | null; 1750 + }; 1751 + url: '/api/v{api-version}/collectionFormat'; 1752 + }; 1753 + 1754 + export type TypesData = { 1755 + body?: never; 1756 + path?: { 1757 + /** 1758 + * This is a number parameter 1759 + */ 1760 + id?: number; 1761 + }; 1762 + query: { 1763 + /** 1764 + * This is a number parameter 1765 + */ 1766 + parameterNumber: number; 1767 + /** 1768 + * This is a string parameter 1769 + */ 1770 + parameterString: string | null; 1771 + /** 1772 + * This is a boolean parameter 1773 + */ 1774 + parameterBoolean: boolean | null; 1775 + /** 1776 + * This is an object parameter 1777 + */ 1778 + parameterObject: { 1779 + [key: string]: unknown; 1780 + } | null; 1781 + /** 1782 + * This is an array parameter 1783 + */ 1784 + parameterArray: Array<string> | null; 1785 + /** 1786 + * This is a dictionary parameter 1787 + */ 1788 + parameterDictionary: { 1789 + [key: string]: unknown; 1790 + } | null; 1791 + /** 1792 + * This is an enum parameter 1793 + */ 1794 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1795 + }; 1796 + url: '/api/v{api-version}/types'; 1797 + }; 1798 + 1799 + export type TypesResponses = { 1800 + /** 1801 + * Response is a simple number 1802 + */ 1803 + 200: number; 1804 + /** 1805 + * Response is a simple string 1806 + */ 1807 + 201: string; 1808 + /** 1809 + * Response is a simple boolean 1810 + */ 1811 + 202: boolean; 1812 + /** 1813 + * Response is a simple object 1814 + */ 1815 + 203: { 1816 + [key: string]: unknown; 1817 + }; 1818 + }; 1819 + 1820 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1821 + 1822 + export type UploadFileData = { 1823 + body: Blob | File; 1824 + path: { 1825 + /** 1826 + * api-version should be required in standalone clients 1827 + */ 1828 + 'api-version': string | null; 1829 + }; 1830 + query?: never; 1831 + url: '/api/v{api-version}/upload'; 1832 + }; 1833 + 1834 + export type UploadFileResponses = { 1835 + 200: boolean; 1836 + }; 1837 + 1838 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1839 + 1840 + export type FileResponseData = { 1841 + body?: never; 1842 + path: { 1843 + id: string; 1844 + /** 1845 + * api-version should be required in standalone clients 1846 + */ 1847 + 'api-version': string; 1848 + }; 1849 + query?: never; 1850 + url: '/api/v{api-version}/file/{id}'; 1851 + }; 1852 + 1853 + export type FileResponseResponses = { 1854 + /** 1855 + * Success 1856 + */ 1857 + 200: Blob | File; 1858 + }; 1859 + 1860 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1861 + 1862 + export type ComplexTypesData = { 1863 + body?: never; 1864 + path?: never; 1865 + query: { 1866 + /** 1867 + * Parameter containing object 1868 + */ 1869 + parameterObject: { 1870 + first?: { 1871 + second?: { 1872 + third?: string; 1873 + }; 1874 + }; 1875 + }; 1876 + /** 1877 + * Parameter containing reference 1878 + */ 1879 + parameterReference: ModelWithString; 1880 + }; 1881 + url: '/api/v{api-version}/complex'; 1882 + }; 1883 + 1884 + export type ComplexTypesErrors = { 1885 + /** 1886 + * 400 `server` error 1887 + */ 1888 + 400: unknown; 1889 + /** 1890 + * 500 server error 1891 + */ 1892 + 500: unknown; 1893 + }; 1894 + 1895 + export type ComplexTypesResponses = { 1896 + /** 1897 + * Successful response 1898 + */ 1899 + 200: Array<ModelWithString>; 1900 + }; 1901 + 1902 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1903 + 1904 + export type MultipartResponseData = { 1905 + body?: never; 1906 + path?: never; 1907 + query?: never; 1908 + url: '/api/v{api-version}/multipart'; 1909 + }; 1910 + 1911 + export type MultipartResponseResponses = { 1912 + /** 1913 + * OK 1914 + */ 1915 + 200: { 1916 + file?: Blob | File; 1917 + metadata?: { 1918 + foo?: string; 1919 + bar?: string; 1920 + }; 1921 + }; 1922 + }; 1923 + 1924 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1925 + 1926 + export type MultipartRequestData = { 1927 + body?: { 1928 + content?: Blob | File; 1929 + data?: ModelWithString | null; 1930 + }; 1931 + path?: never; 1932 + query?: never; 1933 + url: '/api/v{api-version}/multipart'; 1934 + }; 1935 + 1936 + export type ComplexParamsData = { 1937 + body?: { 1938 + readonly key: string | null; 1939 + name: string | null; 1940 + enabled?: boolean; 1941 + type: 'Monkey' | 'Horse' | 'Bird'; 1942 + listOfModels?: Array<ModelWithString> | null; 1943 + listOfStrings?: Array<string> | null; 1944 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1945 + readonly user?: { 1946 + readonly id?: number; 1947 + readonly name?: string | null; 1948 + }; 1949 + }; 1950 + path: { 1951 + id: number; 1952 + /** 1953 + * api-version should be required in standalone clients 1954 + */ 1955 + 'api-version': string; 1956 + }; 1957 + query?: never; 1958 + url: '/api/v{api-version}/complex/{id}'; 1959 + }; 1960 + 1961 + export type ComplexParamsResponses = { 1962 + /** 1963 + * Success 1964 + */ 1965 + 200: ModelWithString; 1966 + }; 1967 + 1968 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1969 + 1970 + export type CallWithResultFromHeaderData = { 1971 + body?: never; 1972 + path?: never; 1973 + query?: never; 1974 + url: '/api/v{api-version}/header'; 1975 + }; 1976 + 1977 + export type CallWithResultFromHeaderErrors = { 1978 + /** 1979 + * 400 server error 1980 + */ 1981 + 400: unknown; 1982 + /** 1983 + * 500 server error 1984 + */ 1985 + 500: unknown; 1986 + }; 1987 + 1988 + export type CallWithResultFromHeaderResponses = { 1989 + /** 1990 + * Successful response 1991 + */ 1992 + 200: unknown; 1993 + }; 1994 + 1995 + export type TestErrorCodeData = { 1996 + body?: never; 1997 + path?: never; 1998 + query: { 1999 + /** 2000 + * Status code to return 2001 + */ 2002 + status: number; 2003 + }; 2004 + url: '/api/v{api-version}/error'; 2005 + }; 2006 + 2007 + export type TestErrorCodeErrors = { 2008 + /** 2009 + * Custom message: Internal Server Error 2010 + */ 2011 + 500: unknown; 2012 + /** 2013 + * Custom message: Not Implemented 2014 + */ 2015 + 501: unknown; 2016 + /** 2017 + * Custom message: Bad Gateway 2018 + */ 2019 + 502: unknown; 2020 + /** 2021 + * Custom message: Service Unavailable 2022 + */ 2023 + 503: unknown; 2024 + }; 2025 + 2026 + export type TestErrorCodeResponses = { 2027 + /** 2028 + * Custom message: Successful response 2029 + */ 2030 + 200: unknown; 2031 + }; 2032 + 2033 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2034 + body?: never; 2035 + path?: never; 2036 + query: { 2037 + /** 2038 + * Dummy input param 2039 + */ 2040 + nonAsciiParamæøåÆØÅöôêÊ: number; 2041 + }; 2042 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2043 + }; 2044 + 2045 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2046 + /** 2047 + * Successful response 2048 + */ 2049 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2050 + }; 2051 + 2052 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2053 + 2054 + export type PutWithFormUrlEncodedData = { 2055 + body: ArrayWithStrings; 2056 + path?: never; 2057 + query?: never; 2058 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2059 + }; 2060 + 2061 + export type ClientOptions = { 2062 + baseUrl: 'http://localhost:3000/base' | (string & {}); 2063 + };
+18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ClientOptions } from './types.gen'; 4 + import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; 5 + 6 + /** 7 + * The `createClientConfig()` function will be called on client initialization 8 + * and the returned object will become the client's initial configuration. 9 + * 10 + * You may want to initialize your client this way instead of calling 11 + * `setConfig()`. This is useful for example if you're using Next.js 12 + * to ensure your client always has the correct values. 13 + */ 14 + export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>; 15 + 16 + export const client = createClient(createConfig<ClientOptions>({ 17 + baseURL: 'http://localhost:3000/base' 18 + }));
+229
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/client.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { 4 + useAsyncData, 5 + useFetch, 6 + useLazyAsyncData, 7 + useLazyFetch, 8 + } from 'nuxt/app'; 9 + import { reactive, ref, watch } from 'vue'; 10 + 11 + import { createSseClient } from '../core/serverSentEvents.gen'; 12 + import type { HttpMethod } from '../core/types.gen'; 13 + import type { Client, Config, RequestOptions } from './types.gen'; 14 + import { 15 + buildUrl, 16 + createConfig, 17 + executeFetchFn, 18 + mergeConfigs, 19 + mergeHeaders, 20 + mergeInterceptors, 21 + serializeBody, 22 + setAuthParams, 23 + unwrapRefs, 24 + } from './utils.gen'; 25 + 26 + export const createClient = (config: Config = {}): Client => { 27 + let _config = mergeConfigs(createConfig(), config); 28 + 29 + const getConfig = (): Config => ({ ..._config }); 30 + 31 + const setConfig = (config: Config): Config => { 32 + _config = mergeConfigs(_config, config); 33 + return getConfig(); 34 + }; 35 + 36 + const beforeRequest = async (options: RequestOptions) => { 37 + const opts = { 38 + ..._config, 39 + ...options, 40 + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, 41 + headers: mergeHeaders(_config.headers, options.headers), 42 + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), 43 + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 44 + }; 45 + 46 + if (opts.security) { 47 + await setAuthParams({ 48 + ...opts, 49 + security: opts.security, 50 + }); 51 + } 52 + 53 + if (opts.requestValidator) { 54 + await opts.requestValidator(opts); 55 + } 56 + 57 + const url = buildUrl(opts); 58 + 59 + return { opts, url }; 60 + }; 61 + 62 + const request: Client['request'] = ({ 63 + asyncDataOptions, 64 + composable, 65 + ...options 66 + }) => { 67 + const key = options.key; 68 + const opts = { 69 + ..._config, 70 + ...options, 71 + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, 72 + headers: mergeHeaders(_config.headers, options.headers), 73 + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), 74 + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), 75 + }; 76 + 77 + const { 78 + requestValidator, 79 + responseTransformer, 80 + responseValidator, 81 + security, 82 + } = opts; 83 + if (requestValidator || security) { 84 + // auth must happen in interceptors otherwise we'd need to require 85 + // asyncContext enabled 86 + // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext 87 + opts.onRequest = [ 88 + async ({ options }) => { 89 + if (security) { 90 + await setAuthParams({ 91 + auth: opts.auth, 92 + headers: options.headers, 93 + query: options.query, 94 + security, 95 + }); 96 + } 97 + 98 + if (requestValidator) { 99 + await requestValidator({ 100 + ...options, 101 + // @ts-expect-error 102 + body: options.rawBody, 103 + }); 104 + } 105 + }, 106 + ...opts.onRequest, 107 + ]; 108 + } 109 + 110 + if (responseTransformer || responseValidator) { 111 + opts.onResponse = [ 112 + ...opts.onResponse, 113 + async ({ options, response }) => { 114 + if (options.responseType && options.responseType !== 'json') { 115 + return; 116 + } 117 + 118 + if (!response.ok) { 119 + return; 120 + } 121 + 122 + if (responseValidator) { 123 + await responseValidator(response._data); 124 + } 125 + 126 + if (responseTransformer) { 127 + response._data = await responseTransformer(response._data); 128 + } 129 + }, 130 + ]; 131 + } 132 + 133 + // remove Content-Type header if body is empty to avoid sending invalid requests 134 + if (opts.body === undefined || opts.body === '') { 135 + opts.headers.delete('Content-Type'); 136 + } 137 + 138 + const fetchFn = opts.$fetch; 139 + 140 + if (composable === '$fetch') { 141 + return executeFetchFn( 142 + // @ts-expect-error 143 + opts, 144 + fetchFn, 145 + ); 146 + } 147 + 148 + if (composable === 'useFetch' || composable === 'useLazyFetch') { 149 + opts.rawBody = opts.body; 150 + const bodyParams = reactive({ 151 + body: opts.body, 152 + bodySerializer: opts.bodySerializer, 153 + }); 154 + const body = ref(serializeBody(opts)); 155 + opts.body = body; 156 + watch(bodyParams, (changed) => { 157 + body.value = serializeBody(changed); 158 + }); 159 + return composable === 'useLazyFetch' 160 + ? useLazyFetch(() => buildUrl(opts), opts) 161 + : useFetch(() => buildUrl(opts), opts); 162 + } 163 + 164 + const handler: any = () => 165 + executeFetchFn( 166 + // @ts-expect-error 167 + opts, 168 + fetchFn, 169 + ); 170 + 171 + if (composable === 'useAsyncData') { 172 + return key 173 + ? useAsyncData(key, handler, asyncDataOptions) 174 + : useAsyncData(handler, asyncDataOptions); 175 + } 176 + 177 + if (composable === 'useLazyAsyncData') { 178 + return key 179 + ? useLazyAsyncData(key, handler, asyncDataOptions) 180 + : useLazyAsyncData(handler, asyncDataOptions); 181 + } 182 + 183 + return undefined as any; 184 + }; 185 + 186 + const makeMethodFn = 187 + (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 188 + request({ ...options, method }); 189 + 190 + const makeSseFn = 191 + (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 192 + const { opts, url } = await beforeRequest(options); 193 + return createSseClient({ 194 + ...unwrapRefs(opts), 195 + body: opts.body as BodyInit | null | undefined, 196 + method, 197 + onRequest: undefined, 198 + signal: unwrapRefs(opts.signal) as AbortSignal, 199 + url, 200 + }); 201 + }; 202 + 203 + return { 204 + buildUrl, 205 + connect: makeMethodFn('CONNECT'), 206 + delete: makeMethodFn('DELETE'), 207 + get: makeMethodFn('GET'), 208 + getConfig, 209 + head: makeMethodFn('HEAD'), 210 + options: makeMethodFn('OPTIONS'), 211 + patch: makeMethodFn('PATCH'), 212 + post: makeMethodFn('POST'), 213 + put: makeMethodFn('PUT'), 214 + request, 215 + setConfig, 216 + sse: { 217 + connect: makeSseFn('CONNECT'), 218 + delete: makeSseFn('DELETE'), 219 + get: makeSseFn('GET'), 220 + head: makeSseFn('HEAD'), 221 + options: makeSseFn('OPTIONS'), 222 + patch: makeSseFn('PATCH'), 223 + post: makeSseFn('POST'), 224 + put: makeSseFn('PUT'), 225 + trace: makeSseFn('TRACE'), 226 + }, 227 + trace: makeMethodFn('TRACE'), 228 + } as Client; 229 + };
+24
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { Auth } from '../core/auth.gen'; 4 + export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 + export { 6 + formDataBodySerializer, 7 + jsonBodySerializer, 8 + urlSearchParamsBodySerializer, 9 + } from '../core/bodySerializer.gen'; 10 + export { buildClientParams } from '../core/params.gen'; 11 + export { createClient } from './client.gen'; 12 + export type { 13 + Client, 14 + ClientOptions, 15 + Composable, 16 + Config, 17 + CreateClientConfig, 18 + Options, 19 + OptionsLegacyParser, 20 + RequestOptions, 21 + RequestResult, 22 + TDataShape, 23 + } from './types.gen'; 24 + export { createConfig } from './utils.gen';
+216
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + AsyncDataOptions, 5 + useAsyncData, 6 + useFetch, 7 + UseFetchOptions, 8 + useLazyAsyncData, 9 + useLazyFetch, 10 + } from 'nuxt/app'; 11 + import type { Ref } from 'vue'; 12 + 13 + import type { Auth } from '../core/auth.gen'; 14 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 15 + import type { 16 + ServerSentEventsOptions, 17 + ServerSentEventsResult, 18 + } from '../core/serverSentEvents.gen'; 19 + import type { 20 + Client as CoreClient, 21 + Config as CoreConfig, 22 + } from '../core/types.gen'; 23 + 24 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 25 + type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 26 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 27 + export type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 28 + type ObjectStyle = 'form' | 'deepObject'; 29 + 30 + export type QuerySerializer = ( 31 + query: Parameters<Client['buildUrl']>[0]['query'], 32 + ) => string; 33 + 34 + type WithRefs<TData> = { 35 + [K in keyof TData]: NonNullable<TData[K]> extends object 36 + ? WithRefs<NonNullable<TData[K]>> | Ref<NonNullable<TData[K]>> 37 + : NonNullable<TData[K]> | Ref<NonNullable<TData[K]>>; 38 + }; 39 + 40 + // copied from Nuxt 41 + export type KeysOf<T> = Array< 42 + T extends T ? (keyof T extends string ? keyof T : never) : never 43 + >; 44 + 45 + export interface Config<T extends ClientOptions = ClientOptions> 46 + extends Omit< 47 + FetchOptions<unknown>, 48 + 'baseURL' | 'body' | 'headers' | 'method' | 'query' 49 + >, 50 + WithRefs<Pick<FetchOptions<unknown>, 'query'>>, 51 + Omit<CoreConfig, 'querySerializer'> { 52 + /** 53 + * Base URL for all requests made by this client. 54 + */ 55 + baseURL?: T['baseURL']; 56 + /** 57 + * A function for serializing request query parameters. By default, arrays 58 + * will be exploded in form style, objects will be exploded in deepObject 59 + * style, and reserved characters are percent-encoded. 60 + * 61 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 62 + */ 63 + querySerializer?: QuerySerializer | QuerySerializerOptions; 64 + } 65 + 66 + export interface RequestOptions< 67 + TComposable extends Composable = Composable, 68 + ResT = unknown, 69 + DefaultT = undefined, 70 + Url extends string = string, 71 + > extends Config, 72 + WithRefs<{ 73 + /** 74 + * Any body that you want to add to your request. 75 + * 76 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 77 + */ 78 + body?: unknown; 79 + path?: FetchOptions<unknown>['query']; 80 + query?: FetchOptions<unknown>['query']; 81 + rawBody?: unknown; 82 + }>, 83 + Pick< 84 + ServerSentEventsOptions<ResT>, 85 + | 'onSseError' 86 + | 'onSseEvent' 87 + | 'sseDefaultRetryDelay' 88 + | 'sseMaxRetryAttempts' 89 + | 'sseMaxRetryDelay' 90 + > { 91 + asyncDataOptions?: AsyncDataOptions<ResT, ResT, KeysOf<ResT>, DefaultT>; 92 + composable: TComposable; 93 + key?: string; 94 + /** 95 + * Security mechanism(s) to use for the request. 96 + */ 97 + security?: ReadonlyArray<Auth>; 98 + url: Url; 99 + } 100 + 101 + export type RequestResult< 102 + TComposable extends Composable, 103 + ResT, 104 + TError, 105 + > = TComposable extends '$fetch' 106 + ? ReturnType<typeof $fetch<ResT>> 107 + : TComposable extends 'useAsyncData' 108 + ? ReturnType<typeof useAsyncData<ResT | null, TError>> 109 + : TComposable extends 'useFetch' 110 + ? ReturnType<typeof useFetch<ResT | null, TError>> 111 + : TComposable extends 'useLazyAsyncData' 112 + ? ReturnType<typeof useLazyAsyncData<ResT | null, TError>> 113 + : TComposable extends 'useLazyFetch' 114 + ? ReturnType<typeof useLazyFetch<ResT | null, TError>> 115 + : never; 116 + 117 + export interface ClientOptions { 118 + baseURL?: string; 119 + } 120 + 121 + type MethodFn = < 122 + TComposable extends Composable, 123 + ResT = unknown, 124 + TError = unknown, 125 + DefaultT = undefined, 126 + >( 127 + options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>, 128 + ) => RequestResult<TComposable, ResT, TError>; 129 + 130 + type SseFn = < 131 + TComposable extends Composable, 132 + ResT = unknown, 133 + TError = unknown, 134 + DefaultT = undefined, 135 + >( 136 + options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>, 137 + ) => Promise<ServerSentEventsResult<RequestResult<TComposable, ResT, TError>>>; 138 + 139 + type RequestFn = < 140 + TComposable extends Composable, 141 + ResT = unknown, 142 + TError = unknown, 143 + DefaultT = undefined, 144 + >( 145 + options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'> & 146 + Pick<Required<RequestOptions<TComposable, ResT, DefaultT>>, 'method'>, 147 + ) => RequestResult<TComposable, ResT, TError>; 148 + 149 + /** 150 + * The `createClientConfig()` function will be called on client initialization 151 + * and the returned object will become the client's initial configuration. 152 + * 153 + * You may want to initialize your client this way instead of calling 154 + * `setConfig()`. This is useful for example if you're using Next.js 155 + * to ensure your client always has the correct values. 156 + */ 157 + export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 158 + override?: Config<ClientOptions & T>, 159 + ) => Config<Required<ClientOptions> & T>; 160 + 161 + export interface TDataShape { 162 + body?: unknown; 163 + headers?: unknown; 164 + path?: FetchOptions<unknown>['query']; 165 + query?: FetchOptions<unknown>['query']; 166 + url: string; 167 + } 168 + 169 + export type BuildUrlOptions< 170 + TData extends Omit<TDataShape, 'headers'> = Omit<TDataShape, 'headers'>, 171 + > = Pick<WithRefs<TData>, 'path' | 'query'> & 172 + Pick<TData, 'url'> & 173 + Pick<Options<'$fetch', TData>, 'baseURL' | 'querySerializer'>; 174 + 175 + type BuildUrlFn = <TData extends Omit<TDataShape, 'headers'>>( 176 + options: BuildUrlOptions<TData>, 177 + ) => string; 178 + 179 + export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn>; 180 + 181 + type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 182 + 183 + export type Options< 184 + TComposable extends Composable, 185 + TData extends TDataShape = TDataShape, 186 + ResT = unknown, 187 + DefaultT = undefined, 188 + > = OmitKeys< 189 + RequestOptions<TComposable, ResT, DefaultT>, 190 + 'body' | 'path' | 'query' | 'url' 191 + > & 192 + WithRefs<Omit<TData, 'url'>>; 193 + 194 + export type OptionsLegacyParser<TData = unknown> = TData extends { body?: any } 195 + ? TData extends { headers?: any } 196 + ? OmitKeys<RequestOptions, 'body' | 'headers' | 'url'> & TData 197 + : OmitKeys<RequestOptions, 'body' | 'url'> & 198 + TData & 199 + Pick<RequestOptions, 'headers'> 200 + : TData extends { headers?: any } 201 + ? OmitKeys<RequestOptions, 'headers' | 'url'> & 202 + TData & 203 + Pick<RequestOptions, 'body'> 204 + : OmitKeys<RequestOptions, 'url'> & TData; 205 + 206 + type FetchOptions<TData> = Omit< 207 + UseFetchOptions<TData, TData>, 208 + keyof AsyncDataOptions<TData> 209 + >; 210 + 211 + export type Composable = 212 + | '$fetch' 213 + | 'useAsyncData' 214 + | 'useFetch' 215 + | 'useLazyAsyncData' 216 + | 'useLazyFetch';
+381
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { ComputedRef, Ref } from 'vue'; 4 + import { isRef, toValue, unref } from 'vue'; 5 + 6 + import { getAuthToken } from '../core/auth.gen'; 7 + import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 8 + import { jsonBodySerializer } from '../core/bodySerializer.gen'; 9 + import { 10 + serializeArrayParam, 11 + serializeObjectParam, 12 + serializePrimitiveParam, 13 + } from '../core/pathSerializer.gen'; 14 + import type { 15 + ArraySeparatorStyle, 16 + BuildUrlOptions, 17 + Client, 18 + ClientOptions, 19 + Config, 20 + QuerySerializer, 21 + RequestOptions, 22 + } from './types.gen'; 23 + 24 + type PathSerializer = Pick<Required<BuildUrlOptions>, 'path' | 'url'>; 25 + 26 + const PATH_PARAM_RE = /\{[^{}]+\}/g; 27 + 28 + type MaybeArray<T> = T | T[]; 29 + 30 + const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 31 + let url = _url; 32 + const matches = _url.match(PATH_PARAM_RE); 33 + if (matches) { 34 + for (const match of matches) { 35 + let explode = false; 36 + let name = match.substring(1, match.length - 1); 37 + let style: ArraySeparatorStyle = 'simple'; 38 + 39 + if (name.endsWith('*')) { 40 + explode = true; 41 + name = name.substring(0, name.length - 1); 42 + } 43 + 44 + if (name.startsWith('.')) { 45 + name = name.substring(1); 46 + style = 'label'; 47 + } else if (name.startsWith(';')) { 48 + name = name.substring(1); 49 + style = 'matrix'; 50 + } 51 + 52 + const value = toValue(toValue(path)[name]); 53 + 54 + if (value === undefined || value === null) { 55 + continue; 56 + } 57 + 58 + if (Array.isArray(value)) { 59 + url = url.replace( 60 + match, 61 + serializeArrayParam({ explode, name, style, value }), 62 + ); 63 + continue; 64 + } 65 + 66 + if (typeof value === 'object') { 67 + url = url.replace( 68 + match, 69 + serializeObjectParam({ 70 + explode, 71 + name, 72 + style, 73 + value: value as Record<string, unknown>, 74 + valueOnly: true, 75 + }), 76 + ); 77 + continue; 78 + } 79 + 80 + if (style === 'matrix') { 81 + url = url.replace( 82 + match, 83 + `;${serializePrimitiveParam({ 84 + name, 85 + value: value as string, 86 + })}`, 87 + ); 88 + continue; 89 + } 90 + 91 + const replaceValue = encodeURIComponent( 92 + style === 'label' ? `.${value as string}` : (value as string), 93 + ); 94 + url = url.replace(match, replaceValue); 95 + } 96 + } 97 + return url; 98 + }; 99 + 100 + export const createQuerySerializer = <T = unknown>({ 101 + allowReserved, 102 + array, 103 + object, 104 + }: QuerySerializerOptions = {}) => { 105 + const querySerializer = (queryParams: T) => { 106 + const search: string[] = []; 107 + const qParams = toValue(queryParams); 108 + if (qParams && typeof qParams === 'object') { 109 + for (const name in qParams) { 110 + const value = toValue(qParams[name]); 111 + 112 + if (value === undefined || value === null) { 113 + continue; 114 + } 115 + 116 + if (Array.isArray(value)) { 117 + const serializedArray = serializeArrayParam({ 118 + allowReserved, 119 + explode: true, 120 + name, 121 + style: 'form', 122 + value, 123 + ...array, 124 + }); 125 + if (serializedArray) search.push(serializedArray); 126 + } else if (typeof value === 'object') { 127 + const serializedObject = serializeObjectParam({ 128 + allowReserved, 129 + explode: true, 130 + name, 131 + style: 'deepObject', 132 + value: value as Record<string, unknown>, 133 + ...object, 134 + }); 135 + if (serializedObject) search.push(serializedObject); 136 + } else { 137 + const serializedPrimitive = serializePrimitiveParam({ 138 + allowReserved, 139 + name, 140 + value: value as string, 141 + }); 142 + if (serializedPrimitive) search.push(serializedPrimitive); 143 + } 144 + } 145 + } 146 + return search.join('&'); 147 + }; 148 + return querySerializer; 149 + }; 150 + 151 + const checkForExistence = ( 152 + options: Pick<RequestOptions, 'auth' | 'query'> & { 153 + headers: Headers; 154 + }, 155 + name?: string, 156 + ): boolean => { 157 + if (!name) { 158 + return false; 159 + } 160 + if ( 161 + options.headers.has(name) || 162 + toValue(options.query)?.[name] || 163 + options.headers.get('Cookie')?.includes(`${name}=`) 164 + ) { 165 + return true; 166 + } 167 + return false; 168 + }; 169 + 170 + export const setAuthParams = async ({ 171 + security, 172 + ...options 173 + }: Pick<Required<RequestOptions>, 'security'> & 174 + Pick<RequestOptions, 'auth' | 'query'> & { 175 + headers: Headers; 176 + }) => { 177 + for (const auth of security) { 178 + if (checkForExistence(options, auth.name)) { 179 + continue; 180 + } 181 + const token = await getAuthToken(auth, options.auth); 182 + 183 + if (!token) { 184 + continue; 185 + } 186 + 187 + const name = auth.name ?? 'Authorization'; 188 + 189 + switch (auth.in) { 190 + case 'query': 191 + if (!options.query) { 192 + options.query = {}; 193 + } 194 + toValue(options.query)[name] = token; 195 + break; 196 + case 'cookie': 197 + options.headers.append('Cookie', `${name}=${token}`); 198 + break; 199 + case 'header': 200 + default: 201 + options.headers.set(name, token); 202 + break; 203 + } 204 + } 205 + }; 206 + 207 + export const buildUrl: Client['buildUrl'] = (options) => { 208 + const url = getUrl({ 209 + baseUrl: options.baseURL as string, 210 + path: options.path, 211 + query: options.query, 212 + querySerializer: 213 + typeof options.querySerializer === 'function' 214 + ? options.querySerializer 215 + : createQuerySerializer(options.querySerializer), 216 + url: options.url, 217 + }); 218 + return url; 219 + }; 220 + 221 + export const getUrl = ({ 222 + baseUrl, 223 + path, 224 + query, 225 + querySerializer, 226 + url: _url, 227 + }: Pick<BuildUrlOptions, 'path' | 'query' | 'url'> & { 228 + baseUrl?: string; 229 + querySerializer: QuerySerializer; 230 + }) => { 231 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 232 + let url = (baseUrl ?? '') + pathUrl; 233 + if (path) { 234 + url = defaultPathSerializer({ path, url }); 235 + } 236 + let search = query ? querySerializer(query) : ''; 237 + if (search.startsWith('?')) { 238 + search = search.substring(1); 239 + } 240 + if (search) { 241 + url += `?${search}`; 242 + } 243 + return url; 244 + }; 245 + 246 + export const mergeConfigs = (a: Config, b: Config): Config => { 247 + const config = { ...a, ...b }; 248 + if (config.baseURL?.endsWith('/')) { 249 + config.baseURL = config.baseURL.substring(0, config.baseURL.length - 1); 250 + } 251 + config.headers = mergeHeaders(a.headers, b.headers); 252 + return config; 253 + }; 254 + 255 + export const mergeHeaders = ( 256 + ...headers: Array<Required<Config>['headers'] | undefined> 257 + ): Headers => { 258 + const mergedHeaders = new Headers(); 259 + for (const header of headers) { 260 + if (!header || typeof header !== 'object') { 261 + continue; 262 + } 263 + 264 + let h: unknown = header; 265 + if (isRef(h)) { 266 + h = unref(h); 267 + } 268 + 269 + const iterator = 270 + h instanceof Headers 271 + ? h.entries() 272 + : Object.entries(h as Record<string, unknown>); 273 + 274 + for (const [key, value] of iterator) { 275 + if (value === null) { 276 + mergedHeaders.delete(key); 277 + } else if (Array.isArray(value)) { 278 + for (const v of value) { 279 + mergedHeaders.append(key, unwrapRefs(v) as string); 280 + } 281 + } else if (value !== undefined) { 282 + const v = unwrapRefs(value); 283 + // assume object headers are meant to be JSON stringified, i.e. their 284 + // content value in OpenAPI specification is 'application/json' 285 + mergedHeaders.set( 286 + key, 287 + typeof v === 'object' ? JSON.stringify(v) : (v as string), 288 + ); 289 + } 290 + } 291 + } 292 + return mergedHeaders; 293 + }; 294 + 295 + export const mergeInterceptors = <T>(...args: Array<MaybeArray<T>>): Array<T> => 296 + args.reduce<Array<T>>((acc, item) => { 297 + if (typeof item === 'function') { 298 + acc.push(item); 299 + } else if (Array.isArray(item)) { 300 + return acc.concat(item); 301 + } 302 + return acc; 303 + }, []); 304 + 305 + const defaultQuerySerializer = createQuerySerializer({ 306 + allowReserved: false, 307 + array: { 308 + explode: true, 309 + style: 'form', 310 + }, 311 + object: { 312 + explode: true, 313 + style: 'deepObject', 314 + }, 315 + }); 316 + 317 + const defaultHeaders = { 318 + 'Content-Type': 'application/json', 319 + }; 320 + 321 + export const createConfig = <T extends ClientOptions = ClientOptions>( 322 + override: Config<Omit<ClientOptions, keyof T> & T> = {}, 323 + ): Config<Omit<ClientOptions, keyof T> & T> => ({ 324 + ...jsonBodySerializer, 325 + headers: defaultHeaders, 326 + querySerializer: defaultQuerySerializer, 327 + ...override, 328 + }); 329 + 330 + type UnwrapRefs<T> = 331 + T extends Ref<infer V> 332 + ? V 333 + : T extends ComputedRef<infer V> 334 + ? V 335 + : T extends Record<string, unknown> // this doesn't handle functions well 336 + ? { [K in keyof T]: UnwrapRefs<T[K]> } 337 + : T; 338 + 339 + export const unwrapRefs = <T>(value: T): UnwrapRefs<T> => { 340 + if (value === null || typeof value !== 'object' || value instanceof Headers) { 341 + return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 342 + } 343 + 344 + if (Array.isArray(value)) { 345 + return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 346 + } 347 + 348 + if (isRef(value)) { 349 + return unwrapRefs(unref(value) as T); 350 + } 351 + 352 + // unwrap into new object to avoid modifying the source 353 + const result: Record<string, unknown> = {}; 354 + for (const key in value) { 355 + result[key] = unwrapRefs(value[key] as T); 356 + } 357 + return result as UnwrapRefs<T>; 358 + }; 359 + 360 + export const serializeBody = ( 361 + opts: Pick<Parameters<Client['request']>[0], 'body' | 'bodySerializer'>, 362 + ) => { 363 + if (opts.body && opts.bodySerializer) { 364 + return opts.bodySerializer(opts.body); 365 + } 366 + return opts.body; 367 + }; 368 + 369 + export const executeFetchFn = ( 370 + opts: Omit<Parameters<Client['request']>[0], 'composable'>, 371 + fetchFn: Required<Config>['$fetch'], 372 + ) => { 373 + const unwrappedOpts = unwrapRefs(opts); 374 + unwrappedOpts.rawBody = unwrappedOpts.body; 375 + unwrappedOpts.body = serializeBody(unwrappedOpts); 376 + return fetchFn( 377 + buildUrl(opts), 378 + // @ts-expect-error 379 + unwrappedOpts, 380 + ); 381 + };
+42
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/auth.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type AuthToken = string | undefined; 4 + 5 + export interface Auth { 6 + /** 7 + * Which part of the request do we use to send the auth? 8 + * 9 + * @default 'header' 10 + */ 11 + in?: 'header' | 'query' | 'cookie'; 12 + /** 13 + * Header or query parameter name. 14 + * 15 + * @default 'Authorization' 16 + */ 17 + name?: string; 18 + scheme?: 'basic' | 'bearer'; 19 + type: 'apiKey' | 'http'; 20 + } 21 + 22 + export const getAuthToken = async ( 23 + auth: Auth, 24 + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 + ): Promise<string | undefined> => { 26 + const token = 27 + typeof callback === 'function' ? await callback(auth) : callback; 28 + 29 + if (!token) { 30 + return; 31 + } 32 + 33 + if (auth.scheme === 'bearer') { 34 + return `Bearer ${token}`; 35 + } 36 + 37 + if (auth.scheme === 'basic') { 38 + return `Basic ${btoa(token)}`; 39 + } 40 + 41 + return token; 42 + };
+92
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/bodySerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { 4 + ArrayStyle, 5 + ObjectStyle, 6 + SerializerOptions, 7 + } from './pathSerializer.gen'; 8 + 9 + export type QuerySerializer = (query: Record<string, unknown>) => string; 10 + 11 + export type BodySerializer = (body: any) => any; 12 + 13 + export interface QuerySerializerOptions { 14 + allowReserved?: boolean; 15 + array?: SerializerOptions<ArrayStyle>; 16 + object?: SerializerOptions<ObjectStyle>; 17 + } 18 + 19 + const serializeFormDataPair = ( 20 + data: FormData, 21 + key: string, 22 + value: unknown, 23 + ): void => { 24 + if (typeof value === 'string' || value instanceof Blob) { 25 + data.append(key, value); 26 + } else if (value instanceof Date) { 27 + data.append(key, value.toISOString()); 28 + } else { 29 + data.append(key, JSON.stringify(value)); 30 + } 31 + }; 32 + 33 + const serializeUrlSearchParamsPair = ( 34 + data: URLSearchParams, 35 + key: string, 36 + value: unknown, 37 + ): void => { 38 + if (typeof value === 'string') { 39 + data.append(key, value); 40 + } else { 41 + data.append(key, JSON.stringify(value)); 42 + } 43 + }; 44 + 45 + export const formDataBodySerializer = { 46 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 47 + body: T, 48 + ): FormData => { 49 + const data = new FormData(); 50 + 51 + Object.entries(body).forEach(([key, value]) => { 52 + if (value === undefined || value === null) { 53 + return; 54 + } 55 + if (Array.isArray(value)) { 56 + value.forEach((v) => serializeFormDataPair(data, key, v)); 57 + } else { 58 + serializeFormDataPair(data, key, value); 59 + } 60 + }); 61 + 62 + return data; 63 + }, 64 + }; 65 + 66 + export const jsonBodySerializer = { 67 + bodySerializer: <T>(body: T): string => 68 + JSON.stringify(body, (_key, value) => 69 + typeof value === 'bigint' ? value.toString() : value, 70 + ), 71 + }; 72 + 73 + export const urlSearchParamsBodySerializer = { 74 + bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>( 75 + body: T, 76 + ): string => { 77 + const data = new URLSearchParams(); 78 + 79 + Object.entries(body).forEach(([key, value]) => { 80 + if (value === undefined || value === null) { 81 + return; 82 + } 83 + if (Array.isArray(value)) { 84 + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 85 + } else { 86 + serializeUrlSearchParamsPair(data, key, value); 87 + } 88 + }); 89 + 90 + return data.toString(); 91 + }, 92 + };
+153
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/params.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + type Slot = 'body' | 'headers' | 'path' | 'query'; 4 + 5 + export type Field = 6 + | { 7 + in: Exclude<Slot, 'body'>; 8 + /** 9 + * Field name. This is the name we want the user to see and use. 10 + */ 11 + key: string; 12 + /** 13 + * Field mapped name. This is the name we want to use in the request. 14 + * If omitted, we use the same value as `key`. 15 + */ 16 + map?: string; 17 + } 18 + | { 19 + in: Extract<Slot, 'body'>; 20 + /** 21 + * Key isn't required for bodies. 22 + */ 23 + key?: string; 24 + map?: string; 25 + }; 26 + 27 + export interface Fields { 28 + allowExtra?: Partial<Record<Slot, boolean>>; 29 + args?: ReadonlyArray<Field>; 30 + } 31 + 32 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 33 + 34 + const extraPrefixesMap: Record<string, Slot> = { 35 + $body_: 'body', 36 + $headers_: 'headers', 37 + $path_: 'path', 38 + $query_: 'query', 39 + }; 40 + const extraPrefixes = Object.entries(extraPrefixesMap); 41 + 42 + type KeyMap = Map< 43 + string, 44 + { 45 + in: Slot; 46 + map?: string; 47 + } 48 + >; 49 + 50 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 51 + if (!map) { 52 + map = new Map(); 53 + } 54 + 55 + for (const config of fields) { 56 + if ('in' in config) { 57 + if (config.key) { 58 + map.set(config.key, { 59 + in: config.in, 60 + map: config.map, 61 + }); 62 + } 63 + } else if (config.args) { 64 + buildKeyMap(config.args, map); 65 + } 66 + } 67 + 68 + return map; 69 + }; 70 + 71 + interface Params { 72 + body: unknown; 73 + headers: Record<string, unknown>; 74 + path: Record<string, unknown>; 75 + query: Record<string, unknown>; 76 + } 77 + 78 + const stripEmptySlots = (params: Params) => { 79 + for (const [slot, value] of Object.entries(params)) { 80 + if (value && typeof value === 'object' && !Object.keys(value).length) { 81 + delete params[slot as Slot]; 82 + } 83 + } 84 + }; 85 + 86 + export const buildClientParams = ( 87 + args: ReadonlyArray<unknown>, 88 + fields: FieldsConfig, 89 + ) => { 90 + const params: Params = { 91 + body: {}, 92 + headers: {}, 93 + path: {}, 94 + query: {}, 95 + }; 96 + 97 + const map = buildKeyMap(fields); 98 + 99 + let config: FieldsConfig[number] | undefined; 100 + 101 + for (const [index, arg] of args.entries()) { 102 + if (fields[index]) { 103 + config = fields[index]; 104 + } 105 + 106 + if (!config) { 107 + continue; 108 + } 109 + 110 + if ('in' in config) { 111 + if (config.key) { 112 + const field = map.get(config.key)!; 113 + const name = field.map || config.key; 114 + (params[field.in] as Record<string, unknown>)[name] = arg; 115 + } else { 116 + params.body = arg; 117 + } 118 + } else { 119 + for (const [key, value] of Object.entries(arg ?? {})) { 120 + const field = map.get(key); 121 + 122 + if (field) { 123 + const name = field.map || key; 124 + (params[field.in] as Record<string, unknown>)[name] = value; 125 + } else { 126 + const extra = extraPrefixes.find(([prefix]) => 127 + key.startsWith(prefix), 128 + ); 129 + 130 + if (extra) { 131 + const [prefix, slot] = extra; 132 + (params[slot] as Record<string, unknown>)[ 133 + key.slice(prefix.length) 134 + ] = value; 135 + } else { 136 + for (const [slot, allowed] of Object.entries( 137 + config.allowExtra ?? {}, 138 + )) { 139 + if (allowed) { 140 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 141 + break; 142 + } 143 + } 144 + } 145 + } 146 + } 147 + } 148 + } 149 + 150 + stripEmptySlots(params); 151 + 152 + return params; 153 + };
+181
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/pathSerializer.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + interface SerializeOptions<T> 4 + extends SerializePrimitiveOptions, 5 + SerializerOptions<T> {} 6 + 7 + interface SerializePrimitiveOptions { 8 + allowReserved?: boolean; 9 + name: string; 10 + } 11 + 12 + export interface SerializerOptions<T> { 13 + /** 14 + * @default true 15 + */ 16 + explode: boolean; 17 + style: T; 18 + } 19 + 20 + export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 21 + export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 22 + type MatrixStyle = 'label' | 'matrix' | 'simple'; 23 + export type ObjectStyle = 'form' | 'deepObject'; 24 + type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 25 + 26 + interface SerializePrimitiveParam extends SerializePrimitiveOptions { 27 + value: string; 28 + } 29 + 30 + export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 31 + switch (style) { 32 + case 'label': 33 + return '.'; 34 + case 'matrix': 35 + return ';'; 36 + case 'simple': 37 + return ','; 38 + default: 39 + return '&'; 40 + } 41 + }; 42 + 43 + export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 44 + switch (style) { 45 + case 'form': 46 + return ','; 47 + case 'pipeDelimited': 48 + return '|'; 49 + case 'spaceDelimited': 50 + return '%20'; 51 + default: 52 + return ','; 53 + } 54 + }; 55 + 56 + export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 57 + switch (style) { 58 + case 'label': 59 + return '.'; 60 + case 'matrix': 61 + return ';'; 62 + case 'simple': 63 + return ','; 64 + default: 65 + return '&'; 66 + } 67 + }; 68 + 69 + export const serializeArrayParam = ({ 70 + allowReserved, 71 + explode, 72 + name, 73 + style, 74 + value, 75 + }: SerializeOptions<ArraySeparatorStyle> & { 76 + value: unknown[]; 77 + }) => { 78 + if (!explode) { 79 + const joinedValues = ( 80 + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 81 + ).join(separatorArrayNoExplode(style)); 82 + switch (style) { 83 + case 'label': 84 + return `.${joinedValues}`; 85 + case 'matrix': 86 + return `;${name}=${joinedValues}`; 87 + case 'simple': 88 + return joinedValues; 89 + default: 90 + return `${name}=${joinedValues}`; 91 + } 92 + } 93 + 94 + const separator = separatorArrayExplode(style); 95 + const joinedValues = value 96 + .map((v) => { 97 + if (style === 'label' || style === 'simple') { 98 + return allowReserved ? v : encodeURIComponent(v as string); 99 + } 100 + 101 + return serializePrimitiveParam({ 102 + allowReserved, 103 + name, 104 + value: v as string, 105 + }); 106 + }) 107 + .join(separator); 108 + return style === 'label' || style === 'matrix' 109 + ? separator + joinedValues 110 + : joinedValues; 111 + }; 112 + 113 + export const serializePrimitiveParam = ({ 114 + allowReserved, 115 + name, 116 + value, 117 + }: SerializePrimitiveParam) => { 118 + if (value === undefined || value === null) { 119 + return ''; 120 + } 121 + 122 + if (typeof value === 'object') { 123 + throw new Error( 124 + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 125 + ); 126 + } 127 + 128 + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 129 + }; 130 + 131 + export const serializeObjectParam = ({ 132 + allowReserved, 133 + explode, 134 + name, 135 + style, 136 + value, 137 + valueOnly, 138 + }: SerializeOptions<ObjectSeparatorStyle> & { 139 + value: Record<string, unknown> | Date; 140 + valueOnly?: boolean; 141 + }) => { 142 + if (value instanceof Date) { 143 + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 144 + } 145 + 146 + if (style !== 'deepObject' && !explode) { 147 + let values: string[] = []; 148 + Object.entries(value).forEach(([key, v]) => { 149 + values = [ 150 + ...values, 151 + key, 152 + allowReserved ? (v as string) : encodeURIComponent(v as string), 153 + ]; 154 + }); 155 + const joinedValues = values.join(','); 156 + switch (style) { 157 + case 'form': 158 + return `${name}=${joinedValues}`; 159 + case 'label': 160 + return `.${joinedValues}`; 161 + case 'matrix': 162 + return `;${name}=${joinedValues}`; 163 + default: 164 + return joinedValues; 165 + } 166 + } 167 + 168 + const separator = separatorObjectExplode(style); 169 + const joinedValues = Object.entries(value) 170 + .map(([key, v]) => 171 + serializePrimitiveParam({ 172 + allowReserved, 173 + name: style === 'deepObject' ? `${name}[${key}]` : key, 174 + value: v as string, 175 + }), 176 + ) 177 + .join(separator); 178 + return style === 'label' || style === 'matrix' 179 + ? separator + joinedValues 180 + : joinedValues; 181 + };
+264
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/serverSentEvents.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Config } from './types.gen'; 4 + 5 + export type ServerSentEventsOptions<TData = unknown> = Omit< 6 + RequestInit, 7 + 'method' 8 + > & 9 + Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 + /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 22 + * Callback invoked when a network or parsing error occurs during streaming. 23 + * 24 + * This option applies only if the endpoint returns a stream of events. 25 + * 26 + * @param error The error that occurred. 27 + */ 28 + onSseError?: (error: unknown) => void; 29 + /** 30 + * Callback invoked when an event is streamed from the server. 31 + * 32 + * This option applies only if the endpoint returns a stream of events. 33 + * 34 + * @param event Event streamed from the server. 35 + * @returns Nothing (void). 36 + */ 37 + onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 39 + /** 40 + * Default retry delay in milliseconds. 41 + * 42 + * This option applies only if the endpoint returns a stream of events. 43 + * 44 + * @default 3000 45 + */ 46 + sseDefaultRetryDelay?: number; 47 + /** 48 + * Maximum number of retry attempts before giving up. 49 + */ 50 + sseMaxRetryAttempts?: number; 51 + /** 52 + * Maximum retry delay in milliseconds. 53 + * 54 + * Applies only when exponential backoff is used. 55 + * 56 + * This option applies only if the endpoint returns a stream of events. 57 + * 58 + * @default 30000 59 + */ 60 + sseMaxRetryDelay?: number; 61 + /** 62 + * Optional sleep function for retry backoff. 63 + * 64 + * Defaults to using `setTimeout`. 65 + */ 66 + sseSleepFn?: (ms: number) => Promise<void>; 67 + url: string; 68 + }; 69 + 70 + export interface StreamEvent<TData = unknown> { 71 + data: TData; 72 + event?: string; 73 + id?: string; 74 + retry?: number; 75 + } 76 + 77 + export type ServerSentEventsResult< 78 + TData = unknown, 79 + TReturn = void, 80 + TNext = unknown, 81 + > = { 82 + stream: AsyncGenerator< 83 + TData extends Record<string, unknown> ? TData[keyof TData] : TData, 84 + TReturn, 85 + TNext 86 + >; 87 + }; 88 + 89 + export const createSseClient = <TData = unknown>({ 90 + onRequest, 91 + onSseError, 92 + onSseEvent, 93 + responseTransformer, 94 + responseValidator, 95 + sseDefaultRetryDelay, 96 + sseMaxRetryAttempts, 97 + sseMaxRetryDelay, 98 + sseSleepFn, 99 + url, 100 + ...options 101 + }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 102 + let lastEventId: string | undefined; 103 + 104 + const sleep = 105 + sseSleepFn ?? 106 + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 107 + 108 + const createStream = async function* () { 109 + let retryDelay: number = sseDefaultRetryDelay ?? 3000; 110 + let attempt = 0; 111 + const signal = options.signal ?? new AbortController().signal; 112 + 113 + while (true) { 114 + if (signal.aborted) break; 115 + 116 + attempt++; 117 + 118 + const headers = 119 + options.headers instanceof Headers 120 + ? options.headers 121 + : new Headers(options.headers as Record<string, string> | undefined); 122 + 123 + if (lastEventId !== undefined) { 124 + headers.set('Last-Event-ID', lastEventId); 125 + } 126 + 127 + try { 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 143 + 144 + if (!response.ok) 145 + throw new Error( 146 + `SSE failed: ${response.status} ${response.statusText}`, 147 + ); 148 + 149 + if (!response.body) throw new Error('No body in SSE response'); 150 + 151 + const reader = response.body 152 + .pipeThrough(new TextDecoderStream()) 153 + .getReader(); 154 + 155 + let buffer = ''; 156 + 157 + const abortHandler = () => { 158 + try { 159 + reader.cancel(); 160 + } catch { 161 + // noop 162 + } 163 + }; 164 + 165 + signal.addEventListener('abort', abortHandler); 166 + 167 + try { 168 + while (true) { 169 + const { done, value } = await reader.read(); 170 + if (done) break; 171 + buffer += value; 172 + 173 + const chunks = buffer.split('\n\n'); 174 + buffer = chunks.pop() ?? ''; 175 + 176 + for (const chunk of chunks) { 177 + const lines = chunk.split('\n'); 178 + const dataLines: Array<string> = []; 179 + let eventName: string | undefined; 180 + 181 + for (const line of lines) { 182 + if (line.startsWith('data:')) { 183 + dataLines.push(line.replace(/^data:\s*/, '')); 184 + } else if (line.startsWith('event:')) { 185 + eventName = line.replace(/^event:\s*/, ''); 186 + } else if (line.startsWith('id:')) { 187 + lastEventId = line.replace(/^id:\s*/, ''); 188 + } else if (line.startsWith('retry:')) { 189 + const parsed = Number.parseInt( 190 + line.replace(/^retry:\s*/, ''), 191 + 10, 192 + ); 193 + if (!Number.isNaN(parsed)) { 194 + retryDelay = parsed; 195 + } 196 + } 197 + } 198 + 199 + let data: unknown; 200 + let parsedJson = false; 201 + 202 + if (dataLines.length) { 203 + const rawData = dataLines.join('\n'); 204 + try { 205 + data = JSON.parse(rawData); 206 + parsedJson = true; 207 + } catch { 208 + data = rawData; 209 + } 210 + } 211 + 212 + if (parsedJson) { 213 + if (responseValidator) { 214 + await responseValidator(data); 215 + } 216 + 217 + if (responseTransformer) { 218 + data = await responseTransformer(data); 219 + } 220 + } 221 + 222 + onSseEvent?.({ 223 + data, 224 + event: eventName, 225 + id: lastEventId, 226 + retry: retryDelay, 227 + }); 228 + 229 + if (dataLines.length) { 230 + yield data as any; 231 + } 232 + } 233 + } 234 + } finally { 235 + signal.removeEventListener('abort', abortHandler); 236 + reader.releaseLock(); 237 + } 238 + 239 + break; // exit loop on normal completion 240 + } catch (error) { 241 + // connection failed or aborted; retry after delay 242 + onSseError?.(error); 243 + 244 + if ( 245 + sseMaxRetryAttempts !== undefined && 246 + attempt >= sseMaxRetryAttempts 247 + ) { 248 + break; // stop after firing error 249 + } 250 + 251 + // exponential backoff: double retry each attempt, cap at 30s 252 + const backoff = Math.min( 253 + retryDelay * 2 ** (attempt - 1), 254 + sseMaxRetryDelay ?? 30000, 255 + ); 256 + await sleep(backoff); 257 + } 258 + } 259 + }; 260 + 261 + const stream = createStream(); 262 + 263 + return { stream }; 264 + };
+118
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { Auth, AuthToken } from './auth.gen'; 4 + import type { 5 + BodySerializer, 6 + QuerySerializer, 7 + QuerySerializerOptions, 8 + } from './bodySerializer.gen'; 9 + 10 + export type HttpMethod = 11 + | 'connect' 12 + | 'delete' 13 + | 'get' 14 + | 'head' 15 + | 'options' 16 + | 'patch' 17 + | 'post' 18 + | 'put' 19 + | 'trace'; 20 + 21 + export type Client< 22 + RequestFn = never, 23 + Config = unknown, 24 + MethodFn = never, 25 + BuildUrlFn = never, 26 + SseFn = never, 27 + > = { 28 + /** 29 + * Returns the final request URL. 30 + */ 31 + buildUrl: BuildUrlFn; 32 + getConfig: () => Config; 33 + request: RequestFn; 34 + setConfig: (config: Config) => Config; 35 + } & { 36 + [K in HttpMethod]: MethodFn; 37 + } & ([SseFn] extends [never] 38 + ? { sse?: never } 39 + : { sse: { [K in HttpMethod]: SseFn } }); 40 + 41 + export interface Config { 42 + /** 43 + * Auth token or a function returning auth token. The resolved value will be 44 + * added to the request payload as defined by its `security` array. 45 + */ 46 + auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 47 + /** 48 + * A function for serializing request body parameter. By default, 49 + * {@link JSON.stringify()} will be used. 50 + */ 51 + bodySerializer?: BodySerializer | null; 52 + /** 53 + * An object containing any HTTP headers that you want to pre-populate your 54 + * `Headers` object with. 55 + * 56 + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 57 + */ 58 + headers?: 59 + | RequestInit['headers'] 60 + | Record< 61 + string, 62 + | string 63 + | number 64 + | boolean 65 + | (string | number | boolean)[] 66 + | null 67 + | undefined 68 + | unknown 69 + >; 70 + /** 71 + * The request method. 72 + * 73 + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 74 + */ 75 + method?: Uppercase<HttpMethod>; 76 + /** 77 + * A function for serializing request query parameters. By default, arrays 78 + * will be exploded in form style, objects will be exploded in deepObject 79 + * style, and reserved characters are percent-encoded. 80 + * 81 + * This method will have no effect if the native `paramsSerializer()` Axios 82 + * API function is used. 83 + * 84 + * {@link https://swagger.io/docs/specification/serialization/#query View examples} 85 + */ 86 + querySerializer?: QuerySerializer | QuerySerializerOptions; 87 + /** 88 + * A function validating request data. This is useful if you want to ensure 89 + * the request conforms to the desired shape, so it can be safely sent to 90 + * the server. 91 + */ 92 + requestValidator?: (data: unknown) => Promise<unknown>; 93 + /** 94 + * A function transforming response data before it's returned. This is useful 95 + * for post-processing data, e.g. converting ISO strings into Date objects. 96 + */ 97 + responseTransformer?: (data: unknown) => Promise<unknown>; 98 + /** 99 + * A function validating response data. This is useful if you want to ensure 100 + * the response conforms to the desired shape, so it can be safely passed to 101 + * the transformers and returned to the user. 102 + */ 103 + responseValidator?: (data: unknown) => Promise<unknown>; 104 + } 105 + 106 + type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 107 + ? true 108 + : [T] extends [never | undefined] 109 + ? [undefined] extends [T] 110 + ? false 111 + : true 112 + : false; 113 + 114 + export type OmitNever<T extends Record<string, unknown>> = { 115 + [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true 116 + ? never 117 + : K]: T[K]; 118 + };
+114
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/utils.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import type { QuerySerializer } from './bodySerializer.gen'; 4 + import { 5 + type ArraySeparatorStyle, 6 + serializeArrayParam, 7 + serializeObjectParam, 8 + serializePrimitiveParam, 9 + } from './pathSerializer.gen'; 10 + 11 + export interface PathSerializer { 12 + path: Record<string, unknown>; 13 + url: string; 14 + } 15 + 16 + export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 + 18 + export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 + let url = _url; 20 + const matches = _url.match(PATH_PARAM_RE); 21 + if (matches) { 22 + for (const match of matches) { 23 + let explode = false; 24 + let name = match.substring(1, match.length - 1); 25 + let style: ArraySeparatorStyle = 'simple'; 26 + 27 + if (name.endsWith('*')) { 28 + explode = true; 29 + name = name.substring(0, name.length - 1); 30 + } 31 + 32 + if (name.startsWith('.')) { 33 + name = name.substring(1); 34 + style = 'label'; 35 + } else if (name.startsWith(';')) { 36 + name = name.substring(1); 37 + style = 'matrix'; 38 + } 39 + 40 + const value = path[name]; 41 + 42 + if (value === undefined || value === null) { 43 + continue; 44 + } 45 + 46 + if (Array.isArray(value)) { 47 + url = url.replace( 48 + match, 49 + serializeArrayParam({ explode, name, style, value }), 50 + ); 51 + continue; 52 + } 53 + 54 + if (typeof value === 'object') { 55 + url = url.replace( 56 + match, 57 + serializeObjectParam({ 58 + explode, 59 + name, 60 + style, 61 + value: value as Record<string, unknown>, 62 + valueOnly: true, 63 + }), 64 + ); 65 + continue; 66 + } 67 + 68 + if (style === 'matrix') { 69 + url = url.replace( 70 + match, 71 + `;${serializePrimitiveParam({ 72 + name, 73 + value: value as string, 74 + })}`, 75 + ); 76 + continue; 77 + } 78 + 79 + const replaceValue = encodeURIComponent( 80 + style === 'label' ? `.${value as string}` : (value as string), 81 + ); 82 + url = url.replace(match, replaceValue); 83 + } 84 + } 85 + return url; 86 + }; 87 + 88 + export const getUrl = ({ 89 + baseUrl, 90 + path, 91 + query, 92 + querySerializer, 93 + url: _url, 94 + }: { 95 + baseUrl?: string; 96 + path?: Record<string, unknown>; 97 + query?: Record<string, unknown>; 98 + querySerializer: QuerySerializer; 99 + url: string; 100 + }) => { 101 + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 102 + let url = (baseUrl ?? '') + pathUrl; 103 + if (path) { 104 + url = defaultPathSerializer({ path, url }); 105 + } 106 + let search = query ? querySerializer(query) : ''; 107 + if (search.startsWith('?')) { 108 + search = search.substring(1); 109 + } 110 + if (search) { 111 + url += `?${search}`; 112 + } 113 + return url; 114 + };
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './sdk.gen';
+409
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/sdk.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; 4 + import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; 5 + import { client as _heyApiClient } from './client.gen'; 6 + 7 + export type Options<TComposable extends Composable, TData extends TDataShape = TDataShape, ResT = unknown, DefaultT = undefined> = ClientOptions<TComposable, TData, ResT, DefaultT> & { 8 + /** 9 + * You can provide a client instance returned by `createClient()` instead of 10 + * individual options. This might be also useful if you want to implement a 11 + * custom client. 12 + */ 13 + client?: Client; 14 + /** 15 + * You can pass arbitrary values through the `meta` object. This can be 16 + * used to access values that aren't defined as part of the SDK function. 17 + */ 18 + meta?: Record<string, unknown>; 19 + }; 20 + 21 + export const export_ = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, ExportData, unknown, DefaultT>) => { 22 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 23 + url: '/api/v{api-version}/no+tag', 24 + ...options 25 + }); 26 + }; 27 + 28 + export const patchApiVbyApiVersionNoTag = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PatchApiVbyApiVersionNoTagData, unknown, DefaultT>) => { 29 + return (options.client ?? _heyApiClient).patch<TComposable, unknown | DefaultT, unknown, DefaultT>({ 30 + url: '/api/v{api-version}/no+tag', 31 + ...options 32 + }); 33 + }; 34 + 35 + export const import_ = <TComposable extends Composable, DefaultT extends ImportResponse = ImportResponse>(options: Options<TComposable, ImportData, ImportResponse, DefaultT>) => { 36 + return (options.client ?? _heyApiClient).post<TComposable, ImportResponse | DefaultT, unknown, DefaultT>({ 37 + url: '/api/v{api-version}/no+tag', 38 + ...options, 39 + headers: { 40 + 'Content-Type': 'application/json', 41 + ...options.headers 42 + } 43 + }); 44 + }; 45 + 46 + export const fooWow = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, FooWowData, unknown, DefaultT>) => { 47 + return (options.client ?? _heyApiClient).put<TComposable, unknown | DefaultT, unknown, DefaultT>({ 48 + url: '/api/v{api-version}/no+tag', 49 + ...options 50 + }); 51 + }; 52 + 53 + export const apiVVersionODataControllerCount = <TComposable extends Composable, DefaultT extends ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponse>(options: Options<TComposable, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, DefaultT>) => { 54 + return (options.client ?? _heyApiClient).get<TComposable, ApiVVersionODataControllerCountResponse | DefaultT, unknown, DefaultT>({ 55 + url: '/api/v{api-version}/simple/$count', 56 + ...options 57 + }); 58 + }; 59 + 60 + export const getApiVbyApiVersionSimpleOperation = <TComposable extends Composable, DefaultT extends GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponse>(options: Options<TComposable, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DefaultT>) => { 61 + return (options.client ?? _heyApiClient).get<TComposable, GetApiVbyApiVersionSimpleOperationResponse | DefaultT, GetApiVbyApiVersionSimpleOperationError, DefaultT>({ 62 + url: '/api/v{api-version}/simple:operation', 63 + ...options 64 + }); 65 + }; 66 + 67 + export const deleteCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DeleteCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 68 + return (options.client ?? _heyApiClient).delete<TComposable, unknown | DefaultT, unknown, DefaultT>({ 69 + url: '/api/v{api-version}/simple', 70 + ...options 71 + }); 72 + }; 73 + 74 + export const getCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, GetCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 75 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 76 + url: '/api/v{api-version}/simple', 77 + ...options 78 + }); 79 + }; 80 + 81 + export const headCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, HeadCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 82 + return (options.client ?? _heyApiClient).head<TComposable, unknown | DefaultT, unknown, DefaultT>({ 83 + url: '/api/v{api-version}/simple', 84 + ...options 85 + }); 86 + }; 87 + 88 + export const optionsCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, OptionsCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 89 + return (options.client ?? _heyApiClient).options<TComposable, unknown | DefaultT, unknown, DefaultT>({ 90 + url: '/api/v{api-version}/simple', 91 + ...options 92 + }); 93 + }; 94 + 95 + export const patchCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PatchCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 96 + return (options.client ?? _heyApiClient).patch<TComposable, unknown | DefaultT, unknown, DefaultT>({ 97 + url: '/api/v{api-version}/simple', 98 + ...options 99 + }); 100 + }; 101 + 102 + export const postCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PostCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 103 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 104 + url: '/api/v{api-version}/simple', 105 + ...options 106 + }); 107 + }; 108 + 109 + export const putCallWithoutParametersAndResponse = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PutCallWithoutParametersAndResponseData, unknown, DefaultT>) => { 110 + return (options.client ?? _heyApiClient).put<TComposable, unknown | DefaultT, unknown, DefaultT>({ 111 + url: '/api/v{api-version}/simple', 112 + ...options 113 + }); 114 + }; 115 + 116 + export const deleteFoo = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DeleteFooData3, unknown, DefaultT>) => { 117 + return (options.client ?? _heyApiClient).delete<TComposable, unknown | DefaultT, unknown, DefaultT>({ 118 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 119 + ...options 120 + }); 121 + }; 122 + 123 + export const callWithDescriptions = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithDescriptionsData, unknown, DefaultT>) => { 124 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 125 + url: '/api/v{api-version}/descriptions', 126 + ...options 127 + }); 128 + }; 129 + 130 + /** 131 + * @deprecated 132 + */ 133 + export const deprecatedCall = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DeprecatedCallData, unknown, DefaultT>) => { 134 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 135 + url: '/api/v{api-version}/parameters/deprecated', 136 + ...options 137 + }); 138 + }; 139 + 140 + export const callWithParameters = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithParametersData, unknown, DefaultT>) => { 141 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 142 + url: '/api/v{api-version}/parameters/{parameterPath}', 143 + ...options, 144 + headers: { 145 + 'Content-Type': 'application/json', 146 + ...options.headers 147 + } 148 + }); 149 + }; 150 + 151 + export const callWithWeirdParameterNames = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithWeirdParameterNamesData, unknown, DefaultT>) => { 152 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 153 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 154 + ...options, 155 + headers: { 156 + 'Content-Type': 'application/json', 157 + ...options.headers 158 + } 159 + }); 160 + }; 161 + 162 + export const getCallWithOptionalParam = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, GetCallWithOptionalParamData, unknown, DefaultT>) => { 163 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 164 + url: '/api/v{api-version}/parameters', 165 + ...options, 166 + headers: { 167 + 'Content-Type': 'application/json', 168 + ...options.headers 169 + } 170 + }); 171 + }; 172 + 173 + export const postCallWithOptionalParam = <TComposable extends Composable, DefaultT extends PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponse>(options: Options<TComposable, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, DefaultT>) => { 174 + return (options.client ?? _heyApiClient).post<TComposable, PostCallWithOptionalParamResponse | DefaultT, unknown, DefaultT>({ 175 + url: '/api/v{api-version}/parameters', 176 + ...options, 177 + headers: { 178 + 'Content-Type': 'application/json', 179 + ...options.headers 180 + } 181 + }); 182 + }; 183 + 184 + export const postApiVbyApiVersionRequestBody = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PostApiVbyApiVersionRequestBodyData, unknown, DefaultT>) => { 185 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 186 + url: '/api/v{api-version}/requestBody', 187 + ...options, 188 + headers: { 189 + 'Content-Type': 'application/json', 190 + ...options.headers 191 + } 192 + }); 193 + }; 194 + 195 + export const postApiVbyApiVersionFormData = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PostApiVbyApiVersionFormDataData, unknown, DefaultT>) => { 196 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 197 + ...formDataBodySerializer, 198 + url: '/api/v{api-version}/formData', 199 + ...options, 200 + headers: { 201 + 'Content-Type': null, 202 + ...options.headers 203 + } 204 + }); 205 + }; 206 + 207 + export const callWithDefaultParameters = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithDefaultParametersData, unknown, DefaultT>) => { 208 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 209 + url: '/api/v{api-version}/defaults', 210 + ...options 211 + }); 212 + }; 213 + 214 + export const callWithDefaultOptionalParameters = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithDefaultOptionalParametersData, unknown, DefaultT>) => { 215 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 216 + url: '/api/v{api-version}/defaults', 217 + ...options 218 + }); 219 + }; 220 + 221 + export const callToTestOrderOfParams = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallToTestOrderOfParamsData, unknown, DefaultT>) => { 222 + return (options.client ?? _heyApiClient).put<TComposable, unknown | DefaultT, unknown, DefaultT>({ 223 + url: '/api/v{api-version}/defaults', 224 + ...options 225 + }); 226 + }; 227 + 228 + export const duplicateName = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DuplicateNameData, unknown, DefaultT>) => { 229 + return (options.client ?? _heyApiClient).delete<TComposable, unknown | DefaultT, unknown, DefaultT>({ 230 + url: '/api/v{api-version}/duplicate', 231 + ...options 232 + }); 233 + }; 234 + 235 + export const duplicateName2 = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DuplicateName2Data, unknown, DefaultT>) => { 236 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 237 + url: '/api/v{api-version}/duplicate', 238 + ...options 239 + }); 240 + }; 241 + 242 + export const duplicateName3 = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DuplicateName3Data, unknown, DefaultT>) => { 243 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 244 + url: '/api/v{api-version}/duplicate', 245 + ...options 246 + }); 247 + }; 248 + 249 + export const duplicateName4 = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, DuplicateName4Data, unknown, DefaultT>) => { 250 + return (options.client ?? _heyApiClient).put<TComposable, unknown | DefaultT, unknown, DefaultT>({ 251 + url: '/api/v{api-version}/duplicate', 252 + ...options 253 + }); 254 + }; 255 + 256 + export const callWithNoContentResponse = <TComposable extends Composable, DefaultT extends CallWithNoContentResponseResponse = CallWithNoContentResponseResponse>(options: Options<TComposable, CallWithNoContentResponseData, CallWithNoContentResponseResponse, DefaultT>) => { 257 + return (options.client ?? _heyApiClient).get<TComposable, CallWithNoContentResponseResponse | DefaultT, unknown, DefaultT>({ 258 + url: '/api/v{api-version}/no-content', 259 + ...options 260 + }); 261 + }; 262 + 263 + export const callWithResponseAndNoContentResponse = <TComposable extends Composable, DefaultT extends CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponse>(options: Options<TComposable, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DefaultT>) => { 264 + return (options.client ?? _heyApiClient).get<TComposable, CallWithResponseAndNoContentResponseResponse | DefaultT, unknown, DefaultT>({ 265 + url: '/api/v{api-version}/multiple-tags/response-and-no-content', 266 + ...options 267 + }); 268 + }; 269 + 270 + export const dummyA = <TComposable extends Composable, DefaultT extends DummyAResponse = DummyAResponse>(options: Options<TComposable, DummyAData, DummyAResponse, DefaultT>) => { 271 + return (options.client ?? _heyApiClient).get<TComposable, DummyAResponse | DefaultT, unknown, DefaultT>({ 272 + url: '/api/v{api-version}/multiple-tags/a', 273 + ...options 274 + }); 275 + }; 276 + 277 + export const dummyB = <TComposable extends Composable, DefaultT extends DummyBResponse = DummyBResponse>(options: Options<TComposable, DummyBData, DummyBResponse, DefaultT>) => { 278 + return (options.client ?? _heyApiClient).get<TComposable, DummyBResponse | DefaultT, unknown, DefaultT>({ 279 + url: '/api/v{api-version}/multiple-tags/b', 280 + ...options 281 + }); 282 + }; 283 + 284 + export const callWithResponse = <TComposable extends Composable, DefaultT extends CallWithResponseResponse = CallWithResponseResponse>(options: Options<TComposable, CallWithResponseData, CallWithResponseResponse, DefaultT>) => { 285 + return (options.client ?? _heyApiClient).get<TComposable, CallWithResponseResponse | DefaultT, unknown, DefaultT>({ 286 + url: '/api/v{api-version}/response', 287 + ...options 288 + }); 289 + }; 290 + 291 + export const callWithDuplicateResponses = <TComposable extends Composable, DefaultT extends CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponse>(options: Options<TComposable, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, DefaultT>) => { 292 + return (options.client ?? _heyApiClient).post<TComposable, CallWithDuplicateResponsesResponse | DefaultT, CallWithDuplicateResponsesError, DefaultT>({ 293 + url: '/api/v{api-version}/response', 294 + ...options 295 + }); 296 + }; 297 + 298 + export const callWithResponses = <TComposable extends Composable, DefaultT extends CallWithResponsesResponse = CallWithResponsesResponse>(options: Options<TComposable, CallWithResponsesData, CallWithResponsesResponse, DefaultT>) => { 299 + return (options.client ?? _heyApiClient).put<TComposable, CallWithResponsesResponse | DefaultT, CallWithResponsesError, DefaultT>({ 300 + url: '/api/v{api-version}/response', 301 + ...options 302 + }); 303 + }; 304 + 305 + export const collectionFormat = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CollectionFormatData, unknown, DefaultT>) => { 306 + return (options.client ?? _heyApiClient).get<TComposable, unknown | DefaultT, unknown, DefaultT>({ 307 + url: '/api/v{api-version}/collectionFormat', 308 + ...options 309 + }); 310 + }; 311 + 312 + export const types = <TComposable extends Composable, DefaultT extends TypesResponse = TypesResponse>(options: Options<TComposable, TypesData, TypesResponse, DefaultT>) => { 313 + return (options.client ?? _heyApiClient).get<TComposable, TypesResponse | DefaultT, unknown, DefaultT>({ 314 + url: '/api/v{api-version}/types', 315 + ...options 316 + }); 317 + }; 318 + 319 + export const uploadFile = <TComposable extends Composable, DefaultT extends UploadFileResponse = UploadFileResponse>(options: Options<TComposable, UploadFileData, UploadFileResponse, DefaultT>) => { 320 + return (options.client ?? _heyApiClient).post<TComposable, UploadFileResponse | DefaultT, unknown, DefaultT>({ 321 + ...urlSearchParamsBodySerializer, 322 + url: '/api/v{api-version}/upload', 323 + ...options, 324 + headers: { 325 + 'Content-Type': 'application/x-www-form-urlencoded', 326 + ...options.headers 327 + } 328 + }); 329 + }; 330 + 331 + export const fileResponse = <TComposable extends Composable, DefaultT extends FileResponseResponse = FileResponseResponse>(options: Options<TComposable, FileResponseData, FileResponseResponse, DefaultT>) => { 332 + return (options.client ?? _heyApiClient).get<TComposable, FileResponseResponse | DefaultT, unknown, DefaultT>({ 333 + url: '/api/v{api-version}/file/{id}', 334 + ...options 335 + }); 336 + }; 337 + 338 + export const complexTypes = <TComposable extends Composable, DefaultT extends ComplexTypesResponse = ComplexTypesResponse>(options: Options<TComposable, ComplexTypesData, ComplexTypesResponse, DefaultT>) => { 339 + return (options.client ?? _heyApiClient).get<TComposable, ComplexTypesResponse | DefaultT, unknown, DefaultT>({ 340 + url: '/api/v{api-version}/complex', 341 + ...options 342 + }); 343 + }; 344 + 345 + export const multipartResponse = <TComposable extends Composable, DefaultT extends MultipartResponseResponse = MultipartResponseResponse>(options: Options<TComposable, MultipartResponseData, MultipartResponseResponse, DefaultT>) => { 346 + return (options.client ?? _heyApiClient).get<TComposable, MultipartResponseResponse | DefaultT, unknown, DefaultT>({ 347 + url: '/api/v{api-version}/multipart', 348 + ...options 349 + }); 350 + }; 351 + 352 + export const multipartRequest = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, MultipartRequestData, unknown, DefaultT>) => { 353 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 354 + ...formDataBodySerializer, 355 + url: '/api/v{api-version}/multipart', 356 + ...options, 357 + headers: { 358 + 'Content-Type': null, 359 + ...options.headers 360 + } 361 + }); 362 + }; 363 + 364 + export const complexParams = <TComposable extends Composable, DefaultT extends ComplexParamsResponse = ComplexParamsResponse>(options: Options<TComposable, ComplexParamsData, ComplexParamsResponse, DefaultT>) => { 365 + return (options.client ?? _heyApiClient).put<TComposable, ComplexParamsResponse | DefaultT, unknown, DefaultT>({ 366 + url: '/api/v{api-version}/complex/{id}', 367 + ...options, 368 + headers: { 369 + 'Content-Type': 'application/json-patch+json', 370 + ...options.headers 371 + } 372 + }); 373 + }; 374 + 375 + export const callWithResultFromHeader = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, CallWithResultFromHeaderData, unknown, DefaultT>) => { 376 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 377 + url: '/api/v{api-version}/header', 378 + ...options 379 + }); 380 + }; 381 + 382 + export const testErrorCode = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, TestErrorCodeData, unknown, DefaultT>) => { 383 + return (options.client ?? _heyApiClient).post<TComposable, unknown | DefaultT, unknown, DefaultT>({ 384 + url: '/api/v{api-version}/error', 385 + ...options 386 + }); 387 + }; 388 + 389 + export const nonAsciiæøåÆøÅöôêÊ字符串 = <TComposable extends Composable, DefaultT extends NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Response>(options: Options<TComposable, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, DefaultT>) => { 390 + return (options.client ?? _heyApiClient).post<TComposable, NonAsciiæøåÆøÅöôêÊ字符串Response | DefaultT, unknown, DefaultT>({ 391 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 392 + ...options 393 + }); 394 + }; 395 + 396 + /** 397 + * Login User 398 + */ 399 + export const putWithFormUrlEncoded = <TComposable extends Composable, DefaultT = undefined>(options: Options<TComposable, PutWithFormUrlEncodedData, unknown, DefaultT>) => { 400 + return (options.client ?? _heyApiClient).put<TComposable, unknown | DefaultT, unknown, DefaultT>({ 401 + ...urlSearchParamsBodySerializer, 402 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 403 + ...options, 404 + headers: { 405 + 'Content-Type': 'application/x-www-form-urlencoded', 406 + ...options.headers 407 + } 408 + }); 409 + };
+2063
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * External ref to shared model (A) 10 + */ 11 + export type ExternalRefA = { 12 + id: string; 13 + name?: string; 14 + }; 15 + 16 + /** 17 + * External ref to shared model (B) 18 + */ 19 + export type ExternalRefB = ExternalRefA; 20 + 21 + /** 22 + * Testing multiline comments in string: First line 23 + * Second line 24 + * 25 + * Fourth line 26 + */ 27 + export type CamelCaseCommentWithBreaks = number; 28 + 29 + /** 30 + * Testing multiline comments in string: First line 31 + * Second line 32 + * 33 + * Fourth line 34 + */ 35 + export type CommentWithBreaks = number; 36 + 37 + /** 38 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 39 + */ 40 + export type CommentWithBackticks = number; 41 + 42 + /** 43 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 44 + */ 45 + export type CommentWithBackticksAndQuotes = number; 46 + 47 + /** 48 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 49 + */ 50 + export type CommentWithSlashes = number; 51 + 52 + /** 53 + * Testing expression placeholders in string: ${expression} should work 54 + */ 55 + export type CommentWithExpressionPlaceholders = number; 56 + 57 + /** 58 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 59 + */ 60 + export type CommentWithQuotes = number; 61 + 62 + /** 63 + * Testing reserved characters in string: * inline * and ** inline ** should work 64 + */ 65 + export type CommentWithReservedCharacters = number; 66 + 67 + /** 68 + * This is a simple number 69 + */ 70 + export type SimpleInteger = number; 71 + 72 + /** 73 + * This is a simple boolean 74 + */ 75 + export type SimpleBoolean = boolean; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export type SimpleString = string; 81 + 82 + /** 83 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 84 + */ 85 + export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 86 + 87 + /** 88 + * This is a simple file 89 + */ 90 + export type SimpleFile = Blob | File; 91 + 92 + /** 93 + * This is a simple reference 94 + */ 95 + export type SimpleReference = ModelWithString; 96 + 97 + /** 98 + * This is a simple string 99 + */ 100 + export type SimpleStringWithPattern = string | null; 101 + 102 + /** 103 + * This is a simple enum with strings 104 + */ 105 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 106 + 107 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 108 + 109 + /** 110 + * This is a simple enum with numbers 111 + */ 112 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 113 + 114 + /** 115 + * Success=1,Warning=2,Error=3 116 + */ 117 + export type EnumFromDescription = number; 118 + 119 + /** 120 + * This is a simple enum with numbers 121 + */ 122 + export type EnumWithExtensions = 200 | 400 | 500; 123 + 124 + export type EnumWithXEnumNames = 0 | 1 | 2; 125 + 126 + /** 127 + * This is a simple array with numbers 128 + */ 129 + export type ArrayWithNumbers = Array<number>; 130 + 131 + /** 132 + * This is a simple array with booleans 133 + */ 134 + export type ArrayWithBooleans = Array<boolean>; 135 + 136 + /** 137 + * This is a simple array with strings 138 + */ 139 + export type ArrayWithStrings = Array<string>; 140 + 141 + /** 142 + * This is a simple array with references 143 + */ 144 + export type ArrayWithReferences = Array<ModelWithString>; 145 + 146 + /** 147 + * This is a simple array containing an array 148 + */ 149 + export type ArrayWithArray = Array<Array<ModelWithString>>; 150 + 151 + /** 152 + * This is a simple array with properties 153 + */ 154 + export type ArrayWithProperties = Array<{ 155 + '16x16'?: CamelCaseCommentWithBreaks; 156 + bar?: string; 157 + }>; 158 + 159 + /** 160 + * This is a simple array with any of properties 161 + */ 162 + export type ArrayWithAnyOfProperties = Array<{ 163 + foo?: string; 164 + } | { 165 + bar?: string; 166 + }>; 167 + 168 + export type AnyOfAnyAndNull = { 169 + data?: unknown | null; 170 + }; 171 + 172 + /** 173 + * This is a simple array with any of properties 174 + */ 175 + export type AnyOfArrays = { 176 + results?: Array<{ 177 + foo?: string; 178 + } | { 179 + bar?: string; 180 + }>; 181 + }; 182 + 183 + /** 184 + * This is a string dictionary 185 + */ 186 + export type DictionaryWithString = { 187 + [key: string]: string; 188 + }; 189 + 190 + export type DictionaryWithPropertiesAndAdditionalProperties = { 191 + foo?: number; 192 + bar?: boolean; 193 + [key: string]: string | number | boolean | undefined; 194 + }; 195 + 196 + /** 197 + * This is a string reference 198 + */ 199 + export type DictionaryWithReference = { 200 + [key: string]: ModelWithString; 201 + }; 202 + 203 + /** 204 + * This is a complex dictionary 205 + */ 206 + export type DictionaryWithArray = { 207 + [key: string]: Array<ModelWithString>; 208 + }; 209 + 210 + /** 211 + * This is a string dictionary 212 + */ 213 + export type DictionaryWithDictionary = { 214 + [key: string]: { 215 + [key: string]: string; 216 + }; 217 + }; 218 + 219 + /** 220 + * This is a complex dictionary 221 + */ 222 + export type DictionaryWithProperties = { 223 + [key: string]: { 224 + foo?: string; 225 + bar?: string; 226 + }; 227 + }; 228 + 229 + /** 230 + * This is a model with one number property 231 + */ 232 + export type ModelWithInteger = { 233 + /** 234 + * This is a simple number property 235 + */ 236 + prop?: number; 237 + }; 238 + 239 + /** 240 + * This is a model with one boolean property 241 + */ 242 + export type ModelWithBoolean = { 243 + /** 244 + * This is a simple boolean property 245 + */ 246 + prop?: boolean; 247 + }; 248 + 249 + /** 250 + * This is a model with one string property 251 + */ 252 + export type ModelWithString = { 253 + /** 254 + * This is a simple string property 255 + */ 256 + prop?: string; 257 + }; 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export type ModelWithStringError = { 263 + /** 264 + * This is a simple string property 265 + */ 266 + prop?: string; 267 + }; 268 + 269 + /** 270 + * `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) 271 + */ 272 + export type ModelFromZendesk = string; 273 + 274 + /** 275 + * This is a model with one string property 276 + */ 277 + export type ModelWithNullableString = { 278 + /** 279 + * This is a simple string property 280 + */ 281 + nullableProp1?: string | null; 282 + /** 283 + * This is a simple string property 284 + */ 285 + nullableRequiredProp1: string | null; 286 + /** 287 + * This is a simple string property 288 + */ 289 + nullableProp2?: string | null; 290 + /** 291 + * This is a simple string property 292 + */ 293 + nullableRequiredProp2: string | null; 294 + /** 295 + * This is a simple enum with strings 296 + */ 297 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 298 + }; 299 + 300 + /** 301 + * This is a model with one enum 302 + */ 303 + export type ModelWithEnum = { 304 + /** 305 + * This is a simple enum with strings 306 + */ 307 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 308 + /** 309 + * These are the HTTP error code enums 310 + */ 311 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 312 + /** 313 + * Simple boolean enum 314 + */ 315 + bool?: true; 316 + }; 317 + 318 + /** 319 + * This is a model with one enum with escaped name 320 + */ 321 + export type ModelWithEnumWithHyphen = { 322 + /** 323 + * Foo-Bar-Baz-Qux 324 + */ 325 + 'foo-bar-baz-qux'?: '3.0'; 326 + }; 327 + 328 + /** 329 + * This is a model with one enum 330 + */ 331 + export type ModelWithEnumFromDescription = { 332 + /** 333 + * Success=1,Warning=2,Error=3 334 + */ 335 + test?: number; 336 + }; 337 + 338 + /** 339 + * This is a model with nested enums 340 + */ 341 + export type ModelWithNestedEnums = { 342 + dictionaryWithEnum?: { 343 + [key: string]: 'Success' | 'Warning' | 'Error'; 344 + }; 345 + dictionaryWithEnumFromDescription?: { 346 + [key: string]: number; 347 + }; 348 + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 349 + arrayWithDescription?: Array<number>; 350 + /** 351 + * This is a simple enum with strings 352 + */ 353 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 354 + }; 355 + 356 + /** 357 + * This is a model with one property containing a reference 358 + */ 359 + export type ModelWithReference = { 360 + prop?: ModelWithProperties; 361 + }; 362 + 363 + /** 364 + * This is a model with one property containing an array 365 + */ 366 + export type ModelWithArrayReadOnlyAndWriteOnly = { 367 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 368 + propWithFile?: Array<Blob | File>; 369 + propWithNumber?: Array<number>; 370 + }; 371 + 372 + /** 373 + * This is a model with one property containing an array 374 + */ 375 + export type ModelWithArray = { 376 + prop?: Array<ModelWithString>; 377 + propWithFile?: Array<Blob | File>; 378 + propWithNumber?: Array<number>; 379 + }; 380 + 381 + /** 382 + * This is a model with one property containing a dictionary 383 + */ 384 + export type ModelWithDictionary = { 385 + prop?: { 386 + [key: string]: string; 387 + }; 388 + }; 389 + 390 + /** 391 + * This is a deprecated model with a deprecated property 392 + * @deprecated 393 + */ 394 + export type DeprecatedModel = { 395 + /** 396 + * This is a deprecated property 397 + * @deprecated 398 + */ 399 + prop?: string; 400 + }; 401 + 402 + /** 403 + * This is a model with one property containing a circular reference 404 + */ 405 + export type ModelWithCircularReference = { 406 + prop?: ModelWithCircularReference; 407 + }; 408 + 409 + /** 410 + * This is a model with one property with a 'one of' relationship 411 + */ 412 + export type CompositionWithOneOf = { 413 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 414 + }; 415 + 416 + /** 417 + * This is a model with one property with a 'one of' relationship where the options are not $ref 418 + */ 419 + export type CompositionWithOneOfAnonymous = { 420 + propA?: { 421 + propA?: string; 422 + } | string | number; 423 + }; 424 + 425 + /** 426 + * Circle 427 + */ 428 + export type ModelCircle = { 429 + kind: string; 430 + radius?: number; 431 + }; 432 + 433 + /** 434 + * Square 435 + */ 436 + export type ModelSquare = { 437 + kind: string; 438 + sideLength?: number; 439 + }; 440 + 441 + /** 442 + * This is a model with one property with a 'one of' relationship where the options are not $ref 443 + */ 444 + export type CompositionWithOneOfDiscriminator = ({ 445 + kind: 'circle'; 446 + } & ModelCircle) | ({ 447 + kind: 'square'; 448 + } & ModelSquare); 449 + 450 + /** 451 + * This is a model with one property with a 'any of' relationship 452 + */ 453 + export type CompositionWithAnyOf = { 454 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 455 + }; 456 + 457 + /** 458 + * This is a model with one property with a 'any of' relationship where the options are not $ref 459 + */ 460 + export type CompositionWithAnyOfAnonymous = { 461 + propA?: { 462 + propA?: string; 463 + } | string | number; 464 + }; 465 + 466 + /** 467 + * This is a model with nested 'any of' property with a type null 468 + */ 469 + export type CompositionWithNestedAnyAndTypeNull = { 470 + propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 471 + }; 472 + 473 + export type _3eNum1Период = 'Bird' | 'Dog'; 474 + 475 + export type ConstValue = 'ConstValue'; 476 + 477 + /** 478 + * This is a model with one property with a 'any of' relationship where the options are not $ref 479 + */ 480 + export type CompositionWithNestedAnyOfAndNull = { 481 + /** 482 + * Scopes 483 + */ 484 + propA?: Array<_3eNum1Период | ConstValue> | null; 485 + }; 486 + 487 + /** 488 + * This is a model with one property with a 'one of' relationship 489 + */ 490 + export type CompositionWithOneOfAndNullable = { 491 + propA?: { 492 + boolean?: boolean; 493 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 494 + }; 495 + 496 + /** 497 + * This is a model that contains a simple dictionary within composition 498 + */ 499 + export type CompositionWithOneOfAndSimpleDictionary = { 500 + propA?: boolean | { 501 + [key: string]: number; 502 + }; 503 + }; 504 + 505 + /** 506 + * This is a model that contains a dictionary of simple arrays within composition 507 + */ 508 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 509 + propA?: boolean | { 510 + [key: string]: Array<boolean>; 511 + }; 512 + }; 513 + 514 + /** 515 + * This is a model that contains a dictionary of complex arrays (composited) within composition 516 + */ 517 + export type CompositionWithOneOfAndComplexArrayDictionary = { 518 + propA?: boolean | { 519 + [key: string]: Array<number | string>; 520 + }; 521 + }; 522 + 523 + /** 524 + * This is a model with one property with a 'all of' relationship 525 + */ 526 + export type CompositionWithAllOfAndNullable = { 527 + propA?: ({ 528 + boolean?: boolean; 529 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 530 + }; 531 + 532 + /** 533 + * This is a model with one property with a 'any of' relationship 534 + */ 535 + export type CompositionWithAnyOfAndNullable = { 536 + propA?: { 537 + boolean?: boolean; 538 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 539 + }; 540 + 541 + /** 542 + * This is a base model with two simple optional properties 543 + */ 544 + export type CompositionBaseModel = { 545 + firstName?: string; 546 + lastname?: string; 547 + }; 548 + 549 + /** 550 + * This is a model that extends the base model 551 + */ 552 + export type CompositionExtendedModel = CompositionBaseModel & { 553 + age: number; 554 + firstName: string; 555 + lastname: string; 556 + }; 557 + 558 + /** 559 + * This is a model with one nested property 560 + */ 561 + export type ModelWithProperties = { 562 + required: string; 563 + readonly requiredAndReadOnly: string; 564 + requiredAndNullable: string | null; 565 + string?: string; 566 + number?: number; 567 + boolean?: boolean; 568 + reference?: ModelWithString; 569 + 'property with space'?: string; 570 + default?: string; 571 + try?: string; 572 + readonly '@namespace.string'?: string; 573 + readonly '@namespace.integer'?: number; 574 + }; 575 + 576 + /** 577 + * This is a model with one nested property 578 + */ 579 + export type ModelWithNestedProperties = { 580 + readonly first: { 581 + readonly second: { 582 + readonly third: string | null; 583 + } | null; 584 + } | null; 585 + }; 586 + 587 + /** 588 + * This is a model with duplicated properties 589 + */ 590 + export type ModelWithDuplicateProperties = { 591 + prop?: ModelWithString; 592 + }; 593 + 594 + /** 595 + * This is a model with ordered properties 596 + */ 597 + export type ModelWithOrderedProperties = { 598 + zebra?: string; 599 + apple?: string; 600 + hawaii?: string; 601 + }; 602 + 603 + /** 604 + * This is a model with duplicated imports 605 + */ 606 + export type ModelWithDuplicateImports = { 607 + propA?: ModelWithString; 608 + propB?: ModelWithString; 609 + propC?: ModelWithString; 610 + }; 611 + 612 + /** 613 + * This is a model that extends another model 614 + */ 615 + export type ModelThatExtends = ModelWithString & { 616 + propExtendsA?: string; 617 + propExtendsB?: ModelWithString; 618 + }; 619 + 620 + /** 621 + * This is a model that extends another model 622 + */ 623 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 624 + propExtendsC?: string; 625 + propExtendsD?: ModelWithString; 626 + }; 627 + 628 + /** 629 + * This is a model that contains a some patterns 630 + */ 631 + export type ModelWithPattern = { 632 + key: string; 633 + name: string; 634 + readonly enabled?: boolean; 635 + readonly modified?: string; 636 + id?: string; 637 + text?: string; 638 + patternWithSingleQuotes?: string; 639 + patternWithNewline?: string; 640 + patternWithBacktick?: string; 641 + }; 642 + 643 + export type File = { 644 + /** 645 + * Id 646 + */ 647 + readonly id?: string; 648 + /** 649 + * Updated at 650 + */ 651 + readonly updated_at?: string; 652 + /** 653 + * Created at 654 + */ 655 + readonly created_at?: string; 656 + /** 657 + * Mime 658 + */ 659 + mime: string; 660 + /** 661 + * File 662 + */ 663 + readonly file?: string; 664 + }; 665 + 666 + export type Default = { 667 + name?: string; 668 + }; 669 + 670 + export type Pageable = { 671 + page?: number; 672 + size?: number; 673 + sort?: Array<string>; 674 + }; 675 + 676 + /** 677 + * This is a free-form object without additionalProperties. 678 + */ 679 + export type FreeFormObjectWithoutAdditionalProperties = { 680 + [key: string]: unknown; 681 + }; 682 + 683 + /** 684 + * This is a free-form object with additionalProperties: true. 685 + */ 686 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 687 + [key: string]: unknown; 688 + }; 689 + 690 + /** 691 + * This is a free-form object with additionalProperties: {}. 692 + */ 693 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 694 + [key: string]: unknown; 695 + }; 696 + 697 + export type ModelWithConst = { 698 + String?: 'String'; 699 + number?: 0; 700 + null?: null; 701 + withType?: 'Some string'; 702 + }; 703 + 704 + /** 705 + * This is a model with one property and additionalProperties: true 706 + */ 707 + export type ModelWithAdditionalPropertiesEqTrue = { 708 + /** 709 + * This is a simple string property 710 + */ 711 + prop?: string; 712 + [key: string]: unknown | string | undefined; 713 + }; 714 + 715 + export type NestedAnyOfArraysNullable = { 716 + nullableArray?: Array<string | boolean> | null; 717 + }; 718 + 719 + export type CompositionWithOneOfAndProperties = ({ 720 + foo: SimpleParameter; 721 + } | { 722 + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 723 + }) & { 724 + baz: number | null; 725 + qux: number; 726 + }; 727 + 728 + /** 729 + * An object that can be null 730 + */ 731 + export type NullableObject = { 732 + foo?: string; 733 + } | null; 734 + 735 + /** 736 + * Some % character 737 + */ 738 + export type CharactersInDescription = string; 739 + 740 + export type ModelWithNullableObject = { 741 + data?: NullableObject; 742 + }; 743 + 744 + export type ModelWithOneOfEnum = { 745 + foo: 'Bar'; 746 + } | { 747 + foo: 'Baz'; 748 + } | { 749 + foo: 'Qux'; 750 + } | { 751 + content: string; 752 + foo: 'Quux'; 753 + } | { 754 + content: [ 755 + string, 756 + string 757 + ]; 758 + foo: 'Corge'; 759 + }; 760 + 761 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 762 + 763 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 764 + 765 + export type ModelWithNestedArrayEnumsData = { 766 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 767 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 768 + }; 769 + 770 + export type ModelWithNestedArrayEnums = { 771 + array_strings?: Array<string>; 772 + data?: ModelWithNestedArrayEnumsData; 773 + }; 774 + 775 + export type ModelWithNestedCompositionEnums = { 776 + foo?: ModelWithNestedArrayEnumsDataFoo; 777 + }; 778 + 779 + export type ModelWithReadOnlyAndWriteOnly = { 780 + foo: string; 781 + readonly bar: string; 782 + }; 783 + 784 + export type ModelWithConstantSizeArray = [ 785 + number, 786 + number 787 + ]; 788 + 789 + export type ModelWithAnyOfConstantSizeArray = [ 790 + number | string, 791 + number | string, 792 + number | string 793 + ]; 794 + 795 + export type ModelWithPrefixItemsConstantSizeArray = [ 796 + ModelWithInteger, 797 + number | string, 798 + string 799 + ]; 800 + 801 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 802 + number | null | string, 803 + number | null | string, 804 + number | null | string 805 + ]; 806 + 807 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 808 + number | Import, 809 + number | Import 810 + ]; 811 + 812 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 813 + number & string, 814 + number & string 815 + ]; 816 + 817 + export type ModelWithNumericEnumUnion = { 818 + /** 819 + * Период 820 + */ 821 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 822 + }; 823 + 824 + /** 825 + * Some description with `back ticks` 826 + */ 827 + export type ModelWithBackticksInDescription = { 828 + /** 829 + * The template `that` should be used for parsing and importing the contents of the CSV file. 830 + * 831 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 832 + * <pre> 833 + * [ 834 + * { 835 + * "resourceType": "Asset", 836 + * "identifier": { 837 + * "name": "${1}", 838 + * "domain": { 839 + * "name": "${2}", 840 + * "community": { 841 + * "name": "Some Community" 842 + * } 843 + * } 844 + * }, 845 + * "attributes" : { 846 + * "00000000-0000-0000-0000-000000003115" : [ { 847 + * "value" : "${3}" 848 + * } ], 849 + * "00000000-0000-0000-0000-000000000222" : [ { 850 + * "value" : "${4}" 851 + * } ] 852 + * } 853 + * } 854 + * ] 855 + * </pre> 856 + */ 857 + template?: string; 858 + }; 859 + 860 + export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 861 + baz: number | null; 862 + qux: number; 863 + }; 864 + 865 + /** 866 + * Model used to test deduplication strategy (unused) 867 + */ 868 + export type ParameterSimpleParameterUnused = string; 869 + 870 + /** 871 + * Model used to test deduplication strategy 872 + */ 873 + export type PostServiceWithEmptyTagResponse = string; 874 + 875 + /** 876 + * Model used to test deduplication strategy 877 + */ 878 + export type PostServiceWithEmptyTagResponse2 = string; 879 + 880 + /** 881 + * Model used to test deduplication strategy 882 + */ 883 + export type DeleteFooData = string; 884 + 885 + /** 886 + * Model used to test deduplication strategy 887 + */ 888 + export type DeleteFooData2 = string; 889 + 890 + /** 891 + * Model with restricted keyword name 892 + */ 893 + export type Import = string; 894 + 895 + export type SchemaWithFormRestrictedKeys = { 896 + description?: string; 897 + 'x-enum-descriptions'?: string; 898 + 'x-enum-varnames'?: string; 899 + 'x-enumNames'?: string; 900 + title?: string; 901 + object?: { 902 + description?: string; 903 + 'x-enum-descriptions'?: string; 904 + 'x-enum-varnames'?: string; 905 + 'x-enumNames'?: string; 906 + title?: string; 907 + }; 908 + array?: Array<{ 909 + description?: string; 910 + 'x-enum-descriptions'?: string; 911 + 'x-enum-varnames'?: string; 912 + 'x-enumNames'?: string; 913 + title?: string; 914 + }>; 915 + }; 916 + 917 + /** 918 + * This schema was giving PascalCase transformations a hard time 919 + */ 920 + export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 921 + /** 922 + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 923 + */ 924 + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 925 + }; 926 + 927 + /** 928 + * This schema was giving PascalCase transformations a hard time 929 + */ 930 + export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 931 + /** 932 + * Specifies the target ResourceVersion 933 + */ 934 + resourceVersion?: string; 935 + /** 936 + * Specifies the target UID. 937 + */ 938 + uid?: string; 939 + }; 940 + 941 + export type AdditionalPropertiesUnknownIssue = { 942 + [key: string]: string | number; 943 + }; 944 + 945 + export type AdditionalPropertiesUnknownIssue2 = { 946 + [key: string]: string | number; 947 + }; 948 + 949 + export type AdditionalPropertiesUnknownIssue3 = string & { 950 + entries: { 951 + [key: string]: AdditionalPropertiesUnknownIssue; 952 + }; 953 + }; 954 + 955 + export type AdditionalPropertiesIntegerIssue = { 956 + value: number; 957 + [key: string]: number; 958 + }; 959 + 960 + export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 961 + 962 + export type GenericSchemaDuplicateIssue1SystemBoolean = { 963 + item?: boolean; 964 + error?: string | null; 965 + readonly hasError?: boolean; 966 + data?: { 967 + [key: string]: never; 968 + }; 969 + }; 970 + 971 + export type GenericSchemaDuplicateIssue1SystemString = { 972 + item?: string | null; 973 + error?: string | null; 974 + readonly hasError?: boolean; 975 + }; 976 + 977 + /** 978 + * This is a model with one nested property 979 + */ 980 + export type ModelWithPropertiesWritable = { 981 + required: string; 982 + requiredAndNullable: string | null; 983 + string?: string; 984 + number?: number; 985 + boolean?: boolean; 986 + reference?: ModelWithString; 987 + 'property with space'?: string; 988 + default?: string; 989 + try?: string; 990 + }; 991 + 992 + /** 993 + * This is a model that contains a some patterns 994 + */ 995 + export type ModelWithPatternWritable = { 996 + key: string; 997 + name: string; 998 + id?: string; 999 + text?: string; 1000 + patternWithSingleQuotes?: string; 1001 + patternWithNewline?: string; 1002 + patternWithBacktick?: string; 1003 + }; 1004 + 1005 + export type FileWritable = { 1006 + /** 1007 + * Mime 1008 + */ 1009 + mime: string; 1010 + }; 1011 + 1012 + export type ModelWithReadOnlyAndWriteOnlyWritable = { 1013 + foo: string; 1014 + baz: string; 1015 + }; 1016 + 1017 + export type AdditionalPropertiesUnknownIssueWritable = { 1018 + [key: string]: string | number; 1019 + }; 1020 + 1021 + export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1022 + item?: boolean; 1023 + error?: string | null; 1024 + data?: { 1025 + [key: string]: never; 1026 + }; 1027 + }; 1028 + 1029 + export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1030 + item?: string | null; 1031 + error?: string | null; 1032 + }; 1033 + 1034 + /** 1035 + * This is a reusable parameter 1036 + */ 1037 + export type SimpleParameter = string; 1038 + 1039 + /** 1040 + * Parameter with illegal characters 1041 + */ 1042 + export type XFooBar = ModelWithString; 1043 + 1044 + /** 1045 + * A reusable request body 1046 + */ 1047 + export type SimpleRequestBody = ModelWithString; 1048 + 1049 + /** 1050 + * A reusable request body 1051 + */ 1052 + export type SimpleFormData = ModelWithString; 1053 + 1054 + export type ExportData = { 1055 + body?: never; 1056 + path?: never; 1057 + query?: never; 1058 + url: '/api/v{api-version}/no+tag'; 1059 + }; 1060 + 1061 + export type PatchApiVbyApiVersionNoTagData = { 1062 + body?: never; 1063 + path?: never; 1064 + query?: never; 1065 + url: '/api/v{api-version}/no+tag'; 1066 + }; 1067 + 1068 + export type PatchApiVbyApiVersionNoTagResponses = { 1069 + /** 1070 + * OK 1071 + */ 1072 + default: unknown; 1073 + }; 1074 + 1075 + export type ImportData = { 1076 + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; 1077 + path?: never; 1078 + query?: never; 1079 + url: '/api/v{api-version}/no+tag'; 1080 + }; 1081 + 1082 + export type ImportResponses = { 1083 + /** 1084 + * Success 1085 + */ 1086 + 200: ModelFromZendesk; 1087 + /** 1088 + * Default success response 1089 + */ 1090 + default: ModelWithReadOnlyAndWriteOnly; 1091 + }; 1092 + 1093 + export type ImportResponse = ImportResponses[keyof ImportResponses]; 1094 + 1095 + export type FooWowData = { 1096 + body?: never; 1097 + path?: never; 1098 + query?: never; 1099 + url: '/api/v{api-version}/no+tag'; 1100 + }; 1101 + 1102 + export type FooWowResponses = { 1103 + /** 1104 + * OK 1105 + */ 1106 + default: unknown; 1107 + }; 1108 + 1109 + export type ApiVVersionODataControllerCountData = { 1110 + body?: never; 1111 + path?: never; 1112 + query?: never; 1113 + url: '/api/v{api-version}/simple/$count'; 1114 + }; 1115 + 1116 + export type ApiVVersionODataControllerCountResponses = { 1117 + /** 1118 + * Success 1119 + */ 1120 + 200: ModelFromZendesk; 1121 + }; 1122 + 1123 + export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1124 + 1125 + export type GetApiVbyApiVersionSimpleOperationData = { 1126 + body?: never; 1127 + path: { 1128 + /** 1129 + * foo in method 1130 + */ 1131 + foo_param: string; 1132 + }; 1133 + query?: never; 1134 + url: '/api/v{api-version}/simple:operation'; 1135 + }; 1136 + 1137 + export type GetApiVbyApiVersionSimpleOperationErrors = { 1138 + /** 1139 + * Default error response 1140 + */ 1141 + default: ModelWithBoolean; 1142 + }; 1143 + 1144 + export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1145 + 1146 + export type GetApiVbyApiVersionSimpleOperationResponses = { 1147 + /** 1148 + * Response is a simple number 1149 + */ 1150 + 200: number; 1151 + }; 1152 + 1153 + export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1154 + 1155 + export type DeleteCallWithoutParametersAndResponseData = { 1156 + body?: never; 1157 + path?: never; 1158 + query?: never; 1159 + url: '/api/v{api-version}/simple'; 1160 + }; 1161 + 1162 + export type GetCallWithoutParametersAndResponseData = { 1163 + body?: never; 1164 + path?: never; 1165 + query?: never; 1166 + url: '/api/v{api-version}/simple'; 1167 + }; 1168 + 1169 + export type HeadCallWithoutParametersAndResponseData = { 1170 + body?: never; 1171 + path?: never; 1172 + query?: never; 1173 + url: '/api/v{api-version}/simple'; 1174 + }; 1175 + 1176 + export type OptionsCallWithoutParametersAndResponseData = { 1177 + body?: never; 1178 + path?: never; 1179 + query?: never; 1180 + url: '/api/v{api-version}/simple'; 1181 + }; 1182 + 1183 + export type PatchCallWithoutParametersAndResponseData = { 1184 + body?: never; 1185 + path?: never; 1186 + query?: never; 1187 + url: '/api/v{api-version}/simple'; 1188 + }; 1189 + 1190 + export type PostCallWithoutParametersAndResponseData = { 1191 + body?: never; 1192 + path?: never; 1193 + query?: never; 1194 + url: '/api/v{api-version}/simple'; 1195 + }; 1196 + 1197 + export type PutCallWithoutParametersAndResponseData = { 1198 + body?: never; 1199 + path?: never; 1200 + query?: never; 1201 + url: '/api/v{api-version}/simple'; 1202 + }; 1203 + 1204 + export type DeleteFooData3 = { 1205 + body?: never; 1206 + headers: { 1207 + /** 1208 + * Parameter with illegal characters 1209 + */ 1210 + 'x-Foo-Bar': ModelWithString; 1211 + }; 1212 + path: { 1213 + /** 1214 + * foo in method 1215 + */ 1216 + foo_param: string; 1217 + /** 1218 + * bar in method 1219 + */ 1220 + BarParam: string; 1221 + }; 1222 + query?: never; 1223 + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1224 + }; 1225 + 1226 + export type CallWithDescriptionsData = { 1227 + body?: never; 1228 + path?: never; 1229 + query?: { 1230 + /** 1231 + * Testing multiline comments in string: First line 1232 + * Second line 1233 + * 1234 + * Fourth line 1235 + */ 1236 + parameterWithBreaks?: string; 1237 + /** 1238 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1239 + */ 1240 + parameterWithBackticks?: string; 1241 + /** 1242 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1243 + */ 1244 + parameterWithSlashes?: string; 1245 + /** 1246 + * Testing expression placeholders in string: ${expression} should work 1247 + */ 1248 + parameterWithExpressionPlaceholders?: string; 1249 + /** 1250 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1251 + */ 1252 + parameterWithQuotes?: string; 1253 + /** 1254 + * Testing reserved characters in string: * inline * and ** inline ** should work 1255 + */ 1256 + parameterWithReservedCharacters?: string; 1257 + }; 1258 + url: '/api/v{api-version}/descriptions'; 1259 + }; 1260 + 1261 + export type DeprecatedCallData = { 1262 + body?: never; 1263 + headers: { 1264 + /** 1265 + * This parameter is deprecated 1266 + * @deprecated 1267 + */ 1268 + parameter: DeprecatedModel | null; 1269 + }; 1270 + path?: never; 1271 + query?: never; 1272 + url: '/api/v{api-version}/parameters/deprecated'; 1273 + }; 1274 + 1275 + export type CallWithParametersData = { 1276 + /** 1277 + * This is the parameter that goes into the body 1278 + */ 1279 + body: { 1280 + [key: string]: unknown; 1281 + } | null; 1282 + headers: { 1283 + /** 1284 + * This is the parameter that goes into the header 1285 + */ 1286 + parameterHeader: string | null; 1287 + }; 1288 + path: { 1289 + /** 1290 + * This is the parameter that goes into the path 1291 + */ 1292 + parameterPath: string | null; 1293 + /** 1294 + * api-version should be required in standalone clients 1295 + */ 1296 + 'api-version': string | null; 1297 + }; 1298 + query: { 1299 + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1300 + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1301 + /** 1302 + * This is the parameter that goes into the query params 1303 + */ 1304 + cursor: string | null; 1305 + }; 1306 + url: '/api/v{api-version}/parameters/{parameterPath}'; 1307 + }; 1308 + 1309 + export type CallWithWeirdParameterNamesData = { 1310 + /** 1311 + * This is the parameter that goes into the body 1312 + */ 1313 + body: ModelWithString | null; 1314 + headers: { 1315 + /** 1316 + * This is the parameter that goes into the request header 1317 + */ 1318 + 'parameter.header': string | null; 1319 + }; 1320 + path: { 1321 + /** 1322 + * This is the parameter that goes into the path 1323 + */ 1324 + 'parameter.path.1'?: string; 1325 + /** 1326 + * This is the parameter that goes into the path 1327 + */ 1328 + 'parameter-path-2'?: string; 1329 + /** 1330 + * This is the parameter that goes into the path 1331 + */ 1332 + 'PARAMETER-PATH-3'?: string; 1333 + /** 1334 + * api-version should be required in standalone clients 1335 + */ 1336 + 'api-version': string | null; 1337 + }; 1338 + query: { 1339 + /** 1340 + * This is the parameter with a reserved keyword 1341 + */ 1342 + default?: string; 1343 + /** 1344 + * This is the parameter that goes into the request query params 1345 + */ 1346 + 'parameter-query': string | null; 1347 + }; 1348 + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1349 + }; 1350 + 1351 + export type GetCallWithOptionalParamData = { 1352 + /** 1353 + * This is a required parameter 1354 + */ 1355 + body: ModelWithOneOfEnum; 1356 + path?: never; 1357 + query?: { 1358 + /** 1359 + * This is an optional parameter 1360 + */ 1361 + page?: number; 1362 + }; 1363 + url: '/api/v{api-version}/parameters'; 1364 + }; 1365 + 1366 + export type PostCallWithOptionalParamData = { 1367 + /** 1368 + * This is an optional parameter 1369 + */ 1370 + body?: { 1371 + offset?: number | null; 1372 + }; 1373 + path?: never; 1374 + query: { 1375 + /** 1376 + * This is a required parameter 1377 + */ 1378 + parameter: Pageable; 1379 + }; 1380 + url: '/api/v{api-version}/parameters'; 1381 + }; 1382 + 1383 + export type PostCallWithOptionalParamResponses = { 1384 + /** 1385 + * Response is a simple number 1386 + */ 1387 + 200: number; 1388 + /** 1389 + * Success 1390 + */ 1391 + 204: void; 1392 + }; 1393 + 1394 + export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1395 + 1396 + export type PostApiVbyApiVersionRequestBodyData = { 1397 + /** 1398 + * A reusable request body 1399 + */ 1400 + body?: SimpleRequestBody; 1401 + path?: never; 1402 + query?: { 1403 + /** 1404 + * This is a reusable parameter 1405 + */ 1406 + parameter?: string; 1407 + }; 1408 + url: '/api/v{api-version}/requestBody'; 1409 + }; 1410 + 1411 + export type PostApiVbyApiVersionFormDataData = { 1412 + /** 1413 + * A reusable request body 1414 + */ 1415 + body?: SimpleFormData; 1416 + path?: never; 1417 + query?: { 1418 + /** 1419 + * This is a reusable parameter 1420 + */ 1421 + parameter?: string; 1422 + }; 1423 + url: '/api/v{api-version}/formData'; 1424 + }; 1425 + 1426 + export type CallWithDefaultParametersData = { 1427 + body?: never; 1428 + path?: never; 1429 + query?: { 1430 + /** 1431 + * This is a simple string with default value 1432 + */ 1433 + parameterString?: string | null; 1434 + /** 1435 + * This is a simple number with default value 1436 + */ 1437 + parameterNumber?: number | null; 1438 + /** 1439 + * This is a simple boolean with default value 1440 + */ 1441 + parameterBoolean?: boolean | null; 1442 + /** 1443 + * This is a simple enum with default value 1444 + */ 1445 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1446 + /** 1447 + * This is a simple model with default value 1448 + */ 1449 + parameterModel?: ModelWithString | null; 1450 + }; 1451 + url: '/api/v{api-version}/defaults'; 1452 + }; 1453 + 1454 + export type CallWithDefaultOptionalParametersData = { 1455 + body?: never; 1456 + path?: never; 1457 + query?: { 1458 + /** 1459 + * This is a simple string that is optional with default value 1460 + */ 1461 + parameterString?: string; 1462 + /** 1463 + * This is a simple number that is optional with default value 1464 + */ 1465 + parameterNumber?: number; 1466 + /** 1467 + * This is a simple boolean that is optional with default value 1468 + */ 1469 + parameterBoolean?: boolean; 1470 + /** 1471 + * This is a simple enum that is optional with default value 1472 + */ 1473 + parameterEnum?: 'Success' | 'Warning' | 'Error'; 1474 + /** 1475 + * This is a simple model that is optional with default value 1476 + */ 1477 + parameterModel?: ModelWithString; 1478 + }; 1479 + url: '/api/v{api-version}/defaults'; 1480 + }; 1481 + 1482 + export type CallToTestOrderOfParamsData = { 1483 + body?: never; 1484 + path?: never; 1485 + query: { 1486 + /** 1487 + * This is a optional string with default 1488 + */ 1489 + parameterOptionalStringWithDefault?: string; 1490 + /** 1491 + * This is a optional string with empty default 1492 + */ 1493 + parameterOptionalStringWithEmptyDefault?: string; 1494 + /** 1495 + * This is a optional string with no default 1496 + */ 1497 + parameterOptionalStringWithNoDefault?: string; 1498 + /** 1499 + * This is a string with default 1500 + */ 1501 + parameterStringWithDefault: string; 1502 + /** 1503 + * This is a string with empty default 1504 + */ 1505 + parameterStringWithEmptyDefault: string; 1506 + /** 1507 + * This is a string with no default 1508 + */ 1509 + parameterStringWithNoDefault: string; 1510 + /** 1511 + * This is a string that can be null with no default 1512 + */ 1513 + parameterStringNullableWithNoDefault?: string | null; 1514 + /** 1515 + * This is a string that can be null with default 1516 + */ 1517 + parameterStringNullableWithDefault?: string | null; 1518 + }; 1519 + url: '/api/v{api-version}/defaults'; 1520 + }; 1521 + 1522 + export type DuplicateNameData = { 1523 + body?: never; 1524 + path?: never; 1525 + query?: never; 1526 + url: '/api/v{api-version}/duplicate'; 1527 + }; 1528 + 1529 + export type DuplicateName2Data = { 1530 + body?: never; 1531 + path?: never; 1532 + query?: never; 1533 + url: '/api/v{api-version}/duplicate'; 1534 + }; 1535 + 1536 + export type DuplicateName3Data = { 1537 + body?: never; 1538 + path?: never; 1539 + query?: never; 1540 + url: '/api/v{api-version}/duplicate'; 1541 + }; 1542 + 1543 + export type DuplicateName4Data = { 1544 + body?: never; 1545 + path?: never; 1546 + query?: never; 1547 + url: '/api/v{api-version}/duplicate'; 1548 + }; 1549 + 1550 + export type CallWithNoContentResponseData = { 1551 + body?: never; 1552 + path?: never; 1553 + query?: never; 1554 + url: '/api/v{api-version}/no-content'; 1555 + }; 1556 + 1557 + export type CallWithNoContentResponseResponses = { 1558 + /** 1559 + * Success 1560 + */ 1561 + 204: void; 1562 + }; 1563 + 1564 + export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1565 + 1566 + export type CallWithResponseAndNoContentResponseData = { 1567 + body?: never; 1568 + path?: never; 1569 + query?: never; 1570 + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1571 + }; 1572 + 1573 + export type CallWithResponseAndNoContentResponseResponses = { 1574 + /** 1575 + * Response is a simple number 1576 + */ 1577 + 200: number; 1578 + /** 1579 + * Success 1580 + */ 1581 + 204: void; 1582 + }; 1583 + 1584 + export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1585 + 1586 + export type DummyAData = { 1587 + body?: never; 1588 + path?: never; 1589 + query?: never; 1590 + url: '/api/v{api-version}/multiple-tags/a'; 1591 + }; 1592 + 1593 + export type DummyAResponses = { 1594 + 200: _400; 1595 + }; 1596 + 1597 + export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1598 + 1599 + export type DummyBData = { 1600 + body?: never; 1601 + path?: never; 1602 + query?: never; 1603 + url: '/api/v{api-version}/multiple-tags/b'; 1604 + }; 1605 + 1606 + export type DummyBResponses = { 1607 + /** 1608 + * Success 1609 + */ 1610 + 204: void; 1611 + }; 1612 + 1613 + export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1614 + 1615 + export type CallWithResponseData = { 1616 + body?: never; 1617 + path?: never; 1618 + query?: never; 1619 + url: '/api/v{api-version}/response'; 1620 + }; 1621 + 1622 + export type CallWithResponseResponses = { 1623 + default: Import; 1624 + }; 1625 + 1626 + export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1627 + 1628 + export type CallWithDuplicateResponsesData = { 1629 + body?: never; 1630 + path?: never; 1631 + query?: never; 1632 + url: '/api/v{api-version}/response'; 1633 + }; 1634 + 1635 + export type CallWithDuplicateResponsesErrors = { 1636 + /** 1637 + * Message for 500 error 1638 + */ 1639 + 500: ModelWithStringError; 1640 + /** 1641 + * Message for 501 error 1642 + */ 1643 + 501: ModelWithStringError; 1644 + /** 1645 + * Message for 502 error 1646 + */ 1647 + 502: ModelWithStringError; 1648 + /** 1649 + * Message for 4XX errors 1650 + */ 1651 + '4XX': DictionaryWithArray; 1652 + /** 1653 + * Default error response 1654 + */ 1655 + default: ModelWithBoolean; 1656 + }; 1657 + 1658 + export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1659 + 1660 + export type CallWithDuplicateResponsesResponses = { 1661 + /** 1662 + * Message for 200 response 1663 + */ 1664 + 200: ModelWithBoolean & ModelWithInteger; 1665 + /** 1666 + * Message for 201 response 1667 + */ 1668 + 201: ModelWithString; 1669 + /** 1670 + * Message for 202 response 1671 + */ 1672 + 202: ModelWithString; 1673 + }; 1674 + 1675 + export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1676 + 1677 + export type CallWithResponsesData = { 1678 + body?: never; 1679 + path?: never; 1680 + query?: never; 1681 + url: '/api/v{api-version}/response'; 1682 + }; 1683 + 1684 + export type CallWithResponsesErrors = { 1685 + /** 1686 + * Message for 500 error 1687 + */ 1688 + 500: ModelWithStringError; 1689 + /** 1690 + * Message for 501 error 1691 + */ 1692 + 501: ModelWithStringError; 1693 + /** 1694 + * Message for 502 error 1695 + */ 1696 + 502: ModelWithStringError; 1697 + /** 1698 + * Message for default response 1699 + */ 1700 + default: ModelWithStringError; 1701 + }; 1702 + 1703 + export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1704 + 1705 + export type CallWithResponsesResponses = { 1706 + /** 1707 + * Message for 200 response 1708 + */ 1709 + 200: { 1710 + readonly '@namespace.string'?: string; 1711 + readonly '@namespace.integer'?: number; 1712 + readonly value?: Array<ModelWithString>; 1713 + }; 1714 + /** 1715 + * Message for 201 response 1716 + */ 1717 + 201: ModelThatExtends; 1718 + /** 1719 + * Message for 202 response 1720 + */ 1721 + 202: ModelThatExtendsExtends; 1722 + }; 1723 + 1724 + export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1725 + 1726 + export type CollectionFormatData = { 1727 + body?: never; 1728 + path?: never; 1729 + query: { 1730 + /** 1731 + * This is an array parameter that is sent as csv format (comma-separated values) 1732 + */ 1733 + parameterArrayCSV: Array<string> | null; 1734 + /** 1735 + * This is an array parameter that is sent as ssv format (space-separated values) 1736 + */ 1737 + parameterArraySSV: Array<string> | null; 1738 + /** 1739 + * This is an array parameter that is sent as tsv format (tab-separated values) 1740 + */ 1741 + parameterArrayTSV: Array<string> | null; 1742 + /** 1743 + * This is an array parameter that is sent as pipes format (pipe-separated values) 1744 + */ 1745 + parameterArrayPipes: Array<string> | null; 1746 + /** 1747 + * This is an array parameter that is sent as multi format (multiple parameter instances) 1748 + */ 1749 + parameterArrayMulti: Array<string> | null; 1750 + }; 1751 + url: '/api/v{api-version}/collectionFormat'; 1752 + }; 1753 + 1754 + export type TypesData = { 1755 + body?: never; 1756 + path?: { 1757 + /** 1758 + * This is a number parameter 1759 + */ 1760 + id?: number; 1761 + }; 1762 + query: { 1763 + /** 1764 + * This is a number parameter 1765 + */ 1766 + parameterNumber: number; 1767 + /** 1768 + * This is a string parameter 1769 + */ 1770 + parameterString: string | null; 1771 + /** 1772 + * This is a boolean parameter 1773 + */ 1774 + parameterBoolean: boolean | null; 1775 + /** 1776 + * This is an object parameter 1777 + */ 1778 + parameterObject: { 1779 + [key: string]: unknown; 1780 + } | null; 1781 + /** 1782 + * This is an array parameter 1783 + */ 1784 + parameterArray: Array<string> | null; 1785 + /** 1786 + * This is a dictionary parameter 1787 + */ 1788 + parameterDictionary: { 1789 + [key: string]: unknown; 1790 + } | null; 1791 + /** 1792 + * This is an enum parameter 1793 + */ 1794 + parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1795 + }; 1796 + url: '/api/v{api-version}/types'; 1797 + }; 1798 + 1799 + export type TypesResponses = { 1800 + /** 1801 + * Response is a simple number 1802 + */ 1803 + 200: number; 1804 + /** 1805 + * Response is a simple string 1806 + */ 1807 + 201: string; 1808 + /** 1809 + * Response is a simple boolean 1810 + */ 1811 + 202: boolean; 1812 + /** 1813 + * Response is a simple object 1814 + */ 1815 + 203: { 1816 + [key: string]: unknown; 1817 + }; 1818 + }; 1819 + 1820 + export type TypesResponse = TypesResponses[keyof TypesResponses]; 1821 + 1822 + export type UploadFileData = { 1823 + body: Blob | File; 1824 + path: { 1825 + /** 1826 + * api-version should be required in standalone clients 1827 + */ 1828 + 'api-version': string | null; 1829 + }; 1830 + query?: never; 1831 + url: '/api/v{api-version}/upload'; 1832 + }; 1833 + 1834 + export type UploadFileResponses = { 1835 + 200: boolean; 1836 + }; 1837 + 1838 + export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1839 + 1840 + export type FileResponseData = { 1841 + body?: never; 1842 + path: { 1843 + id: string; 1844 + /** 1845 + * api-version should be required in standalone clients 1846 + */ 1847 + 'api-version': string; 1848 + }; 1849 + query?: never; 1850 + url: '/api/v{api-version}/file/{id}'; 1851 + }; 1852 + 1853 + export type FileResponseResponses = { 1854 + /** 1855 + * Success 1856 + */ 1857 + 200: Blob | File; 1858 + }; 1859 + 1860 + export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1861 + 1862 + export type ComplexTypesData = { 1863 + body?: never; 1864 + path?: never; 1865 + query: { 1866 + /** 1867 + * Parameter containing object 1868 + */ 1869 + parameterObject: { 1870 + first?: { 1871 + second?: { 1872 + third?: string; 1873 + }; 1874 + }; 1875 + }; 1876 + /** 1877 + * Parameter containing reference 1878 + */ 1879 + parameterReference: ModelWithString; 1880 + }; 1881 + url: '/api/v{api-version}/complex'; 1882 + }; 1883 + 1884 + export type ComplexTypesErrors = { 1885 + /** 1886 + * 400 `server` error 1887 + */ 1888 + 400: unknown; 1889 + /** 1890 + * 500 server error 1891 + */ 1892 + 500: unknown; 1893 + }; 1894 + 1895 + export type ComplexTypesResponses = { 1896 + /** 1897 + * Successful response 1898 + */ 1899 + 200: Array<ModelWithString>; 1900 + }; 1901 + 1902 + export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1903 + 1904 + export type MultipartResponseData = { 1905 + body?: never; 1906 + path?: never; 1907 + query?: never; 1908 + url: '/api/v{api-version}/multipart'; 1909 + }; 1910 + 1911 + export type MultipartResponseResponses = { 1912 + /** 1913 + * OK 1914 + */ 1915 + 200: { 1916 + file?: Blob | File; 1917 + metadata?: { 1918 + foo?: string; 1919 + bar?: string; 1920 + }; 1921 + }; 1922 + }; 1923 + 1924 + export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1925 + 1926 + export type MultipartRequestData = { 1927 + body?: { 1928 + content?: Blob | File; 1929 + data?: ModelWithString | null; 1930 + }; 1931 + path?: never; 1932 + query?: never; 1933 + url: '/api/v{api-version}/multipart'; 1934 + }; 1935 + 1936 + export type ComplexParamsData = { 1937 + body?: { 1938 + readonly key: string | null; 1939 + name: string | null; 1940 + enabled?: boolean; 1941 + type: 'Monkey' | 'Horse' | 'Bird'; 1942 + listOfModels?: Array<ModelWithString> | null; 1943 + listOfStrings?: Array<string> | null; 1944 + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1945 + readonly user?: { 1946 + readonly id?: number; 1947 + readonly name?: string | null; 1948 + }; 1949 + }; 1950 + path: { 1951 + id: number; 1952 + /** 1953 + * api-version should be required in standalone clients 1954 + */ 1955 + 'api-version': string; 1956 + }; 1957 + query?: never; 1958 + url: '/api/v{api-version}/complex/{id}'; 1959 + }; 1960 + 1961 + export type ComplexParamsResponses = { 1962 + /** 1963 + * Success 1964 + */ 1965 + 200: ModelWithString; 1966 + }; 1967 + 1968 + export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 1969 + 1970 + export type CallWithResultFromHeaderData = { 1971 + body?: never; 1972 + path?: never; 1973 + query?: never; 1974 + url: '/api/v{api-version}/header'; 1975 + }; 1976 + 1977 + export type CallWithResultFromHeaderErrors = { 1978 + /** 1979 + * 400 server error 1980 + */ 1981 + 400: unknown; 1982 + /** 1983 + * 500 server error 1984 + */ 1985 + 500: unknown; 1986 + }; 1987 + 1988 + export type CallWithResultFromHeaderResponses = { 1989 + /** 1990 + * Successful response 1991 + */ 1992 + 200: unknown; 1993 + }; 1994 + 1995 + export type TestErrorCodeData = { 1996 + body?: never; 1997 + path?: never; 1998 + query: { 1999 + /** 2000 + * Status code to return 2001 + */ 2002 + status: number; 2003 + }; 2004 + url: '/api/v{api-version}/error'; 2005 + }; 2006 + 2007 + export type TestErrorCodeErrors = { 2008 + /** 2009 + * Custom message: Internal Server Error 2010 + */ 2011 + 500: unknown; 2012 + /** 2013 + * Custom message: Not Implemented 2014 + */ 2015 + 501: unknown; 2016 + /** 2017 + * Custom message: Bad Gateway 2018 + */ 2019 + 502: unknown; 2020 + /** 2021 + * Custom message: Service Unavailable 2022 + */ 2023 + 503: unknown; 2024 + }; 2025 + 2026 + export type TestErrorCodeResponses = { 2027 + /** 2028 + * Custom message: Successful response 2029 + */ 2030 + 200: unknown; 2031 + }; 2032 + 2033 + export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2034 + body?: never; 2035 + path?: never; 2036 + query: { 2037 + /** 2038 + * Dummy input param 2039 + */ 2040 + nonAsciiParamæøåÆØÅöôêÊ: number; 2041 + }; 2042 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2043 + }; 2044 + 2045 + export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2046 + /** 2047 + * Successful response 2048 + */ 2049 + 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2050 + }; 2051 + 2052 + export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2053 + 2054 + export type PutWithFormUrlEncodedData = { 2055 + body: ArrayWithStrings; 2056 + path?: never; 2057 + query?: never; 2058 + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2059 + }; 2060 + 2061 + export type ClientOptions = { 2062 + baseURL: 'http://localhost:3000/base' | (string & {}); 2063 + };
+2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+43
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export const enum _110 { 4 + _110 = '1-10', 5 + _1120 = '11-20' 6 + } 7 + 8 + export const enum MyFoo { 9 + myFoo = 'myFoo', 10 + myBar = 'myBar' 11 + } 12 + 13 + export const enum MyFoo2 { 14 + myFoo = 'MyFoo', 15 + myBar = 'MyBar' 16 + } 17 + 18 + export type Foo = 'foo' | 'bar' | null | '' | true | false; 19 + 20 + export const enum Numbers { 21 + _100 = 100, 22 + _200 = 200, 23 + _300 = 300, 24 + '_-100' = -100, 25 + '_-200' = -200, 26 + '_-300' = -300 27 + } 28 + 29 + export type Arrays = [ 30 + 'foo' 31 + ] | [ 32 + 'bar' 33 + ] | [ 34 + 'baz' 35 + ]; 36 + 37 + export type MyFooRef = { 38 + foo?: Array<MyFoo2>; 39 + }; 40 + 41 + export type ClientOptions = { 42 + baseUrl: `${string}://${string}` | (string & {}); 43 + };
+3 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts
··· 1564 1564 1565 1565 export const ModelWithReadOnlyAndWriteOnlySchema = { 1566 1566 type: 'object', 1567 - required: ['foo', 'bar', 'baz'], 1567 + required: ['foo', 'bar'], 1568 1568 properties: { 1569 1569 foo: { 1570 1570 type: 'string' ··· 1996 1996 export const ModelWithPropertiesWritableSchema = { 1997 1997 description: 'This is a model with one nested property', 1998 1998 type: 'object', 1999 - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], 1999 + required: ['required', 'requiredAndNullable'], 2000 2000 properties: { 2001 2001 required: { 2002 2002 type: 'string' ··· 2080 2080 2081 2081 export const ModelWithReadOnlyAndWriteOnlyWritableSchema = { 2082 2082 type: 'object', 2083 - required: ['foo', 'bar', 'baz'], 2083 + required: ['foo', 'baz'], 2084 2084 properties: { 2085 2085 foo: { 2086 2086 type: 'string'
+14 -1
packages/openapi-ts-tests/main/test/clients.test.ts
··· 150 150 }), 151 151 description: 'SDK with NodeNext tsconfig', 152 152 }, 153 + { 154 + config: createConfig({ 155 + output: { 156 + clean: false, 157 + path: 'clean-false', 158 + }, 159 + plugins: [client, '@hey-api/sdk'], 160 + }), 161 + description: 'avoid appending extension multiple times | twice', 162 + }, 153 163 ]; 154 164 155 - it.each(scenarios)('$description', async ({ config }) => { 165 + it.each(scenarios)('$description', async ({ config, description }) => { 156 166 await createClient(config); 167 + if (description.endsWith('twice')) { 168 + await createClient(config); 169 + } 157 170 158 171 const outputPath = 159 172 typeof config.output === 'string' ? config.output : config.output.path;
+10
packages/openapi-ts/CHANGELOG.md
··· 1 1 # @hey-api/openapi-ts 2 2 3 + ## 0.82.1 4 + 5 + ### Patch Changes 6 + 7 + - [#2541](https://github.com/hey-api/openapi-ts/pull/2541) [`ad3c633`](https://github.com/hey-api/openapi-ts/commit/ad3c633b21d241ba72f27828870c354bfc00bd7e) Thanks [@ixnas](https://github.com/ixnas)! - feat(typescript): add `typescript-const` to `enums.mode` for generating TypeScript enums as constants 8 + 9 + - [#2556](https://github.com/hey-api/openapi-ts/pull/2556) [`74c16f2`](https://github.com/hey-api/openapi-ts/commit/74c16f219706d22aebbc166e8bbb95412a2a5b6f) Thanks [@carson2222](https://github.com/carson2222)! - fix(parser): prune `required` array after removing properties 10 + 11 + - [#2559](https://github.com/hey-api/openapi-ts/pull/2559) [`5012a72`](https://github.com/hey-api/openapi-ts/commit/5012a721e7b7064910e5e4056cb4adf3ae63f19b) Thanks [@jgoz](https://github.com/jgoz)! - fix(output): avoid appending `.gen` to file names multiple times when `output.clean` is `false` 12 + 3 13 ## 0.82.0 4 14 5 15 ### Minor Changes
+1 -1
packages/openapi-ts/package.json
··· 1 1 { 2 2 "name": "@hey-api/openapi-ts", 3 - "version": "0.82.0", 3 + "version": "0.82.1", 4 4 "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.", 5 5 "homepage": "https://heyapi.dev/", 6 6 "repository": {
+1 -1
packages/openapi-ts/src/generate/client.ts
··· 144 144 suffix = `.${infix}`; 145 145 146 146 // rename file: foo.ts -> foo.gen.ts 147 - if (name !== 'index') { 147 + if (name !== 'index' && !name.endsWith(suffix)) { 148 148 const renamedFilePath = path.resolve( 149 149 outputPath, 150 150 [name, infix, extension].join('.'),
+28 -14
packages/openapi-ts/src/openApi/__tests__/index.test.ts
··· 120 120 paths: {}, 121 121 }; 122 122 parseOpenApiSpec({ 123 - // @ts-expect-error 124 - config: {}, 123 + config: { 124 + // @ts-expect-error 125 + output: {}, 126 + }, 125 127 spec, 126 128 }); 127 129 expect(parseV3_0_X).toHaveBeenCalled(); ··· 137 139 paths: {}, 138 140 }; 139 141 parseOpenApiSpec({ 140 - // @ts-expect-error 141 - config: {}, 142 + config: { 143 + // @ts-expect-error 144 + output: {}, 145 + }, 142 146 spec, 143 147 }); 144 148 expect(parseV3_0_X).toHaveBeenCalled(); ··· 154 158 paths: {}, 155 159 }; 156 160 parseOpenApiSpec({ 157 - // @ts-expect-error 158 - config: {}, 161 + config: { 162 + // @ts-expect-error 163 + output: {}, 164 + }, 159 165 spec, 160 166 }); 161 167 expect(parseV3_0_X).toHaveBeenCalled(); ··· 171 177 paths: {}, 172 178 }; 173 179 parseOpenApiSpec({ 174 - // @ts-expect-error 175 - config: {}, 180 + config: { 181 + // @ts-expect-error 182 + output: {}, 183 + }, 176 184 spec, 177 185 }); 178 186 expect(parseV3_0_X).toHaveBeenCalled(); ··· 188 196 paths: {}, 189 197 }; 190 198 parseOpenApiSpec({ 191 - // @ts-expect-error 192 - config: {}, 199 + config: { 200 + // @ts-expect-error 201 + output: {}, 202 + }, 193 203 spec, 194 204 }); 195 205 expect(parseV3_0_X).toHaveBeenCalled(); ··· 204 214 openapi: '3.1.0', 205 215 }; 206 216 parseOpenApiSpec({ 207 - // @ts-expect-error 208 - config: {}, 217 + config: { 218 + // @ts-expect-error 219 + output: {}, 220 + }, 209 221 spec, 210 222 }); 211 223 expect(parseV3_1_X).toHaveBeenCalled(); ··· 220 232 openapi: '3.1.1', 221 233 }; 222 234 parseOpenApiSpec({ 223 - // @ts-expect-error 224 - config: {}, 235 + config: { 236 + // @ts-expect-error 237 + output: {}, 238 + }, 225 239 spec, 226 240 }); 227 241 expect(parseV3_1_X).toHaveBeenCalled();
+35 -7
packages/openapi-ts/src/openApi/shared/transforms/readWrite.ts
··· 139 139 scope: 'readOnly' | 'writeOnly', 140 140 ): boolean => { 141 141 if (schema && typeof schema === 'object') { 142 - // Remove $ref if the referenced schema is exclusively the excluded scope 143 - if ( 144 - '$ref' in schema && 145 - typeof (schema as Record<string, unknown>)['$ref'] === 'string' 146 - ) { 147 - const ref = (schema as Record<string, unknown>)['$ref'] as string; 148 - const nodeInfo = graph.nodes.get(ref); 142 + // Handle $ref schemas 143 + if ('$ref' in schema && typeof schema.$ref === 'string') { 144 + const nodeInfo = graph.nodes.get(schema.$ref); 149 145 if (nodeInfo?.scopes) { 150 146 // Only remove $ref if the referenced schema is *exclusively* the excluded scope. 151 147 // This ensures 'normal' or multi-scope schemas are always kept. ··· 197 193 !(value instanceof Array) 198 194 ) { 199 195 const objMap = value as Record<string, unknown>; 196 + // Track removed properties for object schemas to update required array 197 + const removedProperties = new Set<string>(); 198 + 200 199 for (const key of Object.keys(objMap)) { 201 200 const prop = objMap[key]; 202 201 if ( ··· 205 204 (prop as Record<string, unknown>)[scope] === true 206 205 ) { 207 206 delete objMap[key]; 207 + // Track removed properties for object schemas 208 + if (keyword === 'properties') { 209 + removedProperties.add(key); 210 + } 208 211 } else { 209 212 const shouldRemove = pruneSchemaByScope(graph, prop, scope); 210 213 if (shouldRemove) { 211 214 delete objMap[key]; 215 + // Track removed properties for object schemas 216 + if (keyword === 'properties') { 217 + removedProperties.add(key); 218 + } 212 219 } 213 220 } 214 221 } 222 + 223 + // Update required array if properties were removed 224 + if ( 225 + removedProperties.size > 0 && 226 + keyword === 'properties' && 227 + 'required' in schema && 228 + Array.isArray((schema as Record<string, unknown>).required) 229 + ) { 230 + const required = (schema as Record<string, unknown>) 231 + .required as string[]; 232 + const filteredRequired = required.filter( 233 + (prop) => !removedProperties.has(prop), 234 + ); 235 + 236 + if (filteredRequired.length === 0) { 237 + delete (schema as Record<string, unknown>).required; 238 + } else { 239 + (schema as Record<string, unknown>).required = filteredRequired; 240 + } 241 + } 242 + 215 243 if (!Object.keys(objMap).length) { 216 244 delete (schema as Record<string, unknown>)[keyword]; 217 245 }
+3
packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts
··· 1 1 import fs from 'node:fs'; 2 2 3 + import { CodegenProject } from '@hey-api/codegen-core'; 3 4 import type ts from 'typescript'; 4 5 import { describe, expect, it, vi } from 'vitest'; 5 6 ··· 134 135 }, 135 136 context: {} as any, 136 137 dependencies: [], 138 + gen: new CodegenProject(), 137 139 handler: () => {}, 138 140 name: '@hey-api/schemas', 139 141 output: 'schemas', ··· 274 276 }, 275 277 context: {} as any, 276 278 dependencies: [], 279 + gen: new CodegenProject(), 277 280 handler: () => {}, 278 281 name: '@hey-api/schemas', 279 282 output: 'schemas',
+5
packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts
··· 1 1 import fs from 'node:fs'; 2 2 import path from 'node:path'; 3 3 4 + import { CodegenProject } from '@hey-api/codegen-core'; 4 5 import type ts from 'typescript'; 5 6 import { describe, expect, it, vi } from 'vitest'; 6 7 ··· 170 171 }, 171 172 context: {} as any, 172 173 dependencies: [], 174 + gen: new CodegenProject(), 173 175 handler: () => {}, 174 176 name: '@hey-api/sdk', 175 177 output: '', ··· 342 344 }, 343 345 context: {} as any, 344 346 dependencies: [], 347 + gen: new CodegenProject(), 345 348 handler: () => {}, 346 349 name: '@hey-api/sdk', 347 350 output: '', ··· 475 478 }, 476 479 context: {} as any, 477 480 dependencies: [], 481 + gen: new CodegenProject(), 478 482 handler: () => {}, 479 483 name: '@hey-api/sdk', 480 484 output: '', ··· 610 614 }, 611 615 context: {} as any, 612 616 dependencies: [], 617 + gen: new CodegenProject(), 613 618 handler: () => {}, 614 619 name: '@hey-api/sdk', 615 620 output: '',
+2
packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts
··· 1 1 import fs from 'node:fs'; 2 2 3 + import { CodegenProject } from '@hey-api/codegen-core'; 3 4 import type ts from 'typescript'; 4 5 import { describe, expect, it, vi } from 'vitest'; 5 6 ··· 163 164 }, 164 165 context: {} as any, 165 166 dependencies: [], 167 + gen: new CodegenProject(), 166 168 handler: () => {}, 167 169 name: '@hey-api/typescript', 168 170 output: '',
+13 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/plugin-legacy.ts
··· 76 76 ...setUniqueTypeNameArgs, 77 77 }); 78 78 if (created) { 79 + const config = getConfig(); 80 + const pluginTypeScript = config.plugins['@hey-api/typescript']; 79 81 const node = tsc.enumDeclaration({ 82 + asConst: 83 + typeof pluginTypeScript?.config.enums === 'object' && 84 + pluginTypeScript.config.enums.mode === 'typescript-const', 80 85 comments, 81 86 leadingComment, 82 87 name, ··· 176 181 pluginTypeScript?.config && 177 182 typeof pluginTypeScript.config.enums === 'object' && 178 183 pluginTypeScript.config.enums.enabled && 179 - pluginTypeScript.config.enums.mode === 'typescript' 184 + (pluginTypeScript.config.enums.mode === 'typescript' || 185 + pluginTypeScript.config.enums.mode === 'typescript-const') 180 186 ) { 181 187 generateEnum({ 188 + asConst: pluginTypeScript.config.enums.mode === 'typescript-const', 182 189 client, 183 190 comments, 184 191 leadingComment: comment, ··· 237 244 comments[key] = [escapeComment(comment)]; 238 245 } 239 246 }); 247 + const config = getConfig(); 248 + const pluginTypeScript = config.plugins['@hey-api/typescript']; 240 249 onNode( 241 250 tsc.enumDeclaration({ 251 + asConst: 252 + typeof pluginTypeScript?.config.enums === 'object' && 253 + pluginTypeScript.config.enums.mode === 'typescript-const', 242 254 comments, 243 255 leadingComment: [ 244 256 model.description && escapeComment(model.description),
+7 -2
packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts
··· 77 77 if ( 78 78 numberRegExp.test(key) && 79 79 plugin.config.enums.enabled && 80 - plugin.config.enums.mode === 'typescript' 80 + (plugin.config.enums.mode === 'typescript' || 81 + plugin.config.enums.mode === 'typescript-const') 81 82 ) { 82 83 key = `_${key}`; 83 84 } ··· 628 629 }); 629 630 file.add(node); 630 631 return; 631 - } else if (plugin.config.enums.mode === 'typescript') { 632 + } else if ( 633 + plugin.config.enums.mode === 'typescript' || 634 + plugin.config.enums.mode === 'typescript-const' 635 + ) { 632 636 // TypeScript enums support only string and number values 633 637 const shouldCreateTypeScriptEnum = !enumObject.typeofItems.some( 634 638 (type) => type !== 'number' && type !== 'string', 635 639 ); 636 640 if (shouldCreateTypeScriptEnum) { 637 641 const enumNode = tsc.enumDeclaration({ 642 + asConst: plugin.config.enums.mode === 'typescript-const', 638 643 leadingComment: createSchemaComment({ schema }), 639 644 name: nodeInfo.node, 640 645 obj: enumObject.obj,
+3 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts
··· 2 2 import type { DefinePlugin, Plugin } from '../../types'; 3 3 import type { Api } from './api'; 4 4 5 - export type EnumsType = 'javascript' | 'typescript'; 5 + export type EnumsType = 'javascript' | 'typescript' | 'typescript-const'; 6 6 7 7 export type UserConfig = Plugin.Name<'@hey-api/typescript'> & { 8 8 /** ··· 81 81 * Can be: 82 82 * - `javascript`: Generates JavaScript objects 83 83 * - `typescript`: Generates TypeScript enums 84 + * - `typescript-const`: Generates TypeScript const enums 84 85 * 85 86 * @default 'javascript' 86 87 */ ··· 330 331 * Can be: 331 332 * - `javascript`: Generates JavaScript objects 332 333 * - `typescript`: Generates TypeScript enums 334 + * - `typescript-const`: Generates TypeScript const enums 333 335 * 334 336 * @default 'javascript' 335 337 */
+18 -4
packages/openapi-ts/src/plugins/valibot/api.ts
··· 16 16 plugin: ValibotPlugin['Instance']; 17 17 }): ts.ArrowFunction | undefined => { 18 18 const { requests } = plugin.config; 19 - const f = plugin.gen.ensureFile(plugin.output); 19 + // const f = plugin.gen.ensureFile(plugin.output); 20 20 // TODO: replace 21 21 const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ 22 22 // TODO: refactor for better cross-plugin compatibility ··· 31 31 } 32 32 33 33 file.import({ 34 - module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), 34 + module: file.relativePathToFile({ 35 + context: plugin.context, 36 + id: valibotId, 37 + }), 35 38 name: schemaIdentifier.name, 36 39 }); 40 + // file.import({ 41 + // module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), 42 + // name: schemaIdentifier.name, 43 + // }); 37 44 38 45 file.import({ 39 46 alias: identifiers.v.text, ··· 79 86 plugin: ValibotPlugin['Instance']; 80 87 }): ts.ArrowFunction | undefined => { 81 88 const { responses } = plugin.config; 82 - const f = plugin.gen.ensureFile(plugin.output); 89 + // const f = plugin.gen.ensureFile(plugin.output); 83 90 // TODO: replace 84 91 const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ 85 92 // TODO: refactor for better cross-plugin compatibility ··· 94 101 } 95 102 96 103 file.import({ 97 - module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), 104 + module: file.relativePathToFile({ 105 + context: plugin.context, 106 + id: valibotId, 107 + }), 98 108 name: schemaIdentifier.name, 99 109 }); 110 + // file.import({ 111 + // module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), 112 + // name: schemaIdentifier.name, 113 + // }); 100 114 101 115 file.import({ 102 116 alias: identifiers.v.text,
+17 -17
packages/openapi-ts/src/plugins/valibot/plugin.ts
··· 1 1 import ts from 'typescript'; 2 2 3 3 import type { Identifier } from '../../generate/file/types'; 4 - import { TypeScriptRenderer } from '../../generate/renderer'; 4 + // import { TypeScriptRenderer } from '../../generate/renderer'; 5 5 import { deduplicateSchema } from '../../ir/schema'; 6 6 import type { IR } from '../../ir/types'; 7 7 import { tsc } from '../../tsc'; ··· 957 957 }): Array<ts.Expression> => { 958 958 // TODO: replace 959 959 const file = plugin.context.file({ id: valibotId })!; 960 - const f = plugin.gen.ensureFile(plugin.output); 960 + // const f = plugin.gen.ensureFile(plugin.output); 961 961 962 962 let anyType: string | undefined; 963 963 let identifier: ReturnType<typeof file.identifier> | undefined = _identifier; ··· 975 975 namespace: 'value', 976 976 }); 977 977 // TODO: claim unique name 978 - f.addSymbol({ name: '' }); 978 + // f.addSymbol({ name: '' }); 979 979 } 980 980 } 981 981 ··· 1186 1186 }); 1187 1187 file.add(statement); 1188 1188 // TODO: update claimed name 1189 - f.addSymbol({ 1190 - name: identifier.name, 1191 - value: statement, 1192 - }); 1189 + // f.addSymbol({ 1190 + // name: identifier.name, 1191 + // value: statement, 1192 + // }); 1193 1193 1194 1194 return []; 1195 1195 } ··· 1203 1203 id: valibotId, 1204 1204 path: plugin.output, 1205 1205 }); 1206 - const f = plugin.gen.createFile(plugin.output, { 1207 - extension: '.ts', 1208 - path: '{{path}}.gen', 1209 - renderer: new TypeScriptRenderer(), 1210 - }); 1206 + // const f = plugin.gen.createFile(plugin.output, { 1207 + // extension: '.ts', 1208 + // path: '{{path}}.gen', 1209 + // renderer: new TypeScriptRenderer(), 1210 + // }); 1211 1211 1212 1212 file.import({ 1213 1213 alias: identifiers.v.text, 1214 1214 module: 'valibot', 1215 1215 name: '*', 1216 1216 }); 1217 - f.addImport({ from: 'valibot', namespaceImport: identifiers.v.text }); 1217 + // f.addImport({ from: 'valibot', namespaceImport: identifiers.v.text }); 1218 1218 1219 1219 plugin.forEach( 1220 1220 'operation', ··· 1267 1267 }, 1268 1268 ); 1269 1269 1270 - if (plugin.config.exportFromIndex && f.hasContent()) { 1271 - const index = plugin.gen.ensureFile('index'); 1272 - index.addExport({ from: f, namespaceImport: true }); 1273 - } 1270 + // if (plugin.config.exportFromIndex && f.hasContent()) { 1271 + // const index = plugin.gen.ensureFile('index'); 1272 + // index.addExport({ from: f, namespaceImport: true }); 1273 + // } 1274 1274 };
+11 -11
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
··· 1 1 import ts from 'typescript'; 2 2 3 - import { TypeScriptRenderer } from '../../../generate/renderer'; 3 + // import { TypeScriptRenderer } from '../../../generate/renderer'; 4 4 import { deduplicateSchema } from '../../../ir/schema'; 5 5 import type { IR } from '../../../ir/types'; 6 6 import { buildName } from '../../../openApi/shared/utils/name'; ··· 1101 1101 id: zodId, 1102 1102 path: plugin.output, 1103 1103 }); 1104 - const f = plugin.gen.createFile(plugin.output, { 1105 - extension: '.ts', 1106 - path: '{{path}}.gen', 1107 - renderer: new TypeScriptRenderer(), 1108 - }); 1104 + // const f = plugin.gen.createFile(plugin.output, { 1105 + // extension: '.ts', 1106 + // path: '{{path}}.gen', 1107 + // renderer: new TypeScriptRenderer(), 1108 + // }); 1109 1109 1110 1110 file.import({ 1111 1111 module: getZodModule({ plugin }), 1112 1112 name: identifiers.z.text, 1113 1113 }); 1114 - f.addImport({ from: getZodModule({ plugin }), names: [identifiers.z.text] }); 1114 + // f.addImport({ from: getZodModule({ plugin }), names: [identifiers.z.text] }); 1115 1115 1116 1116 plugin.forEach( 1117 1117 'operation', ··· 1174 1174 }, 1175 1175 ); 1176 1176 1177 - if (plugin.config.exportFromIndex && f.hasContent()) { 1178 - const index = plugin.gen.ensureFile('index'); 1179 - index.addExport({ from: f, namespaceImport: true }); 1180 - } 1177 + // if (plugin.config.exportFromIndex && f.hasContent()) { 1178 + // const index = plugin.gen.ensureFile('index'); 1179 + // index.addExport({ from: f, namespaceImport: true }); 1180 + // } 1181 1181 };
+9 -1
packages/openapi-ts/src/tsc/types.ts
··· 747 747 748 748 /** 749 749 * Create enum declaration. Example `export enum T = { X, Y };` 750 + * @param asConst - whether to use const enums. 750 751 * @param comments - comments to add to each property. 751 752 * @param leadingComment - leading comment to add to enum. 752 753 * @param name - the name of the enum. ··· 756 757 export const createEnumDeclaration = < 757 758 T extends Record<string, any> | Array<ObjectValue>, 758 759 >({ 760 + asConst, 759 761 comments: enumMemberComments = {}, 760 762 leadingComment: comments, 761 763 name, 762 764 obj, 763 765 }: { 766 + asConst: boolean; 764 767 comments?: Record<string | number, Comments>; 765 768 leadingComment?: Comments; 766 769 name: string | ts.TypeReferenceNode; ··· 800 803 return enumMember; 801 804 }); 802 805 806 + const defaultModifiers = [createModifier({ keyword: 'export' })]; 807 + const constModifier = asConst 808 + ? [ts.factory.createToken(ts.SyntaxKind.ConstKeyword)] 809 + : []; 810 + const modifiers = [...defaultModifiers, ...constModifier]; 803 811 const node = ts.factory.createEnumDeclaration( 804 - [createModifier({ keyword: 'export' })], 812 + modifiers, 805 813 typeof name === 'string' 806 814 ? createIdentifier({ text: name }) 807 815 : // TODO: https://github.com/hey-api/openapi-ts/issues/2289