diff --git a/examples/openapi-ts-ky/src/client/client/client.gen.ts b/examples/openapi-ts-ky/src/client/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/examples/openapi-ts-ky/src/client/client/client.gen.ts +++ b/examples/openapi-ts-ky/src/client/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/examples/openapi-ts-ky/src/client/client/index.ts b/examples/openapi-ts-ky/src/client/client/index.ts index c2814a610..b295edeca 100644 --- a/examples/openapi-ts-ky/src/client/client/index.ts +++ b/examples/openapi-ts-ky/src/client/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/examples/openapi-ts-ky/src/client/client/types.gen.ts b/examples/openapi-ts-ky/src/client/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/examples/openapi-ts-ky/src/client/client/types.gen.ts +++ b/examples/openapi-ts-ky/src/client/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-false/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-number/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-strict/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/base-url-string/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/clean-false/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/default/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/client.gen.ts index 625820d21..9ea2a97f6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen.ts'; import type { Middleware } from './utils.gen.ts'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/index.ts index 060b8c679..37cf146fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen.ts'; export { createConfig, mergeHeaders } from './utils.gen.ts'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts index 4520427cb..ab35b9836 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/import-file-extension-ts/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen.ts'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen.ts'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-optional/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/client.gen.ts index 3d385fc37..2e7e55c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen'; import type { Middleware } from './utils.gen'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/index.ts index c2814a610..b295edeca 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen'; export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts index 62d18352c..ab60c72a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/sdk-client-required/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/client.gen.ts index cb124b4c6..372abf04d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/client.gen.ts @@ -11,7 +11,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types.gen.js'; import type { Middleware } from './utils.gen.js'; import { @@ -131,41 +130,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/index.ts index 0ee5de838..50acaa57b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/index.ts @@ -20,7 +20,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types.gen.js'; export { createConfig, mergeHeaders } from './utils.gen.js'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts index 10fc8799f..827d27dfd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ky/tsconfig-nodenext-sdk/client/types.gen.ts @@ -1,5 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../core/auth.gen.js'; import type { ServerSentEventsOptions, @@ -13,57 +15,14 @@ import type { Middleware } from './utils.gen.js'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -72,28 +31,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions< diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/client.ts index a5dfb9a55..1d2c11564 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/client.ts @@ -9,7 +9,6 @@ import type { Config, RequestOptions, ResolvedRequestOptions, - RetryOptions, } from './types'; import type { Middleware } from './utils'; import { @@ -129,41 +128,13 @@ export const createClient = (config: Config = {}): Client => { const validBody = getValidRequestBody(opts); const kyOptions: KyOptions = { + ...opts, body: validBody as BodyInit, - cache: opts.cache, - credentials: opts.credentials, - headers: opts.headers, - integrity: opts.integrity, - keepalive: opts.keepalive, method: opts.method as KyOptions['method'], - mode: opts.mode, redirect: 'follow', - referrer: opts.referrer, - referrerPolicy: opts.referrerPolicy, - signal: opts.signal, throwHttpErrors: opts.throwOnError ?? false, - timeout: opts.timeout, - ...opts.kyOptions, }; - if (opts.retry && typeof opts.retry === 'object') { - const retryOpts = opts.retry as RetryOptions; - kyOptions.retry = { - limit: retryOpts.limit ?? 2, - methods: retryOpts.methods as Array< - | 'get' - | 'post' - | 'put' - | 'patch' - | 'head' - | 'delete' - | 'options' - | 'trace' - >, - statusCodes: retryOpts.statusCodes, - }; - } - let request = new Request(url, { body: kyOptions.body as BodyInit, headers: kyOptions.headers as HeadersInit, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/index.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/index.ts index 00f096436..8faab7f63 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/index.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/index.ts @@ -18,7 +18,6 @@ export type { RequestResult, ResolvedRequestOptions, ResponseStyle, - RetryOptions, TDataShape, } from './types'; export { createConfig, mergeHeaders } from './utils'; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts index baba033c9..818c6a035 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts @@ -1,3 +1,5 @@ +import type { KyInstance, Options as KyOptions } from 'ky'; + import type { Auth } from '../../client-core/bundle/auth'; import type { ServerSentEventsOptions, @@ -11,57 +13,14 @@ import type { Middleware } from './utils'; export type ResponseStyle = 'data' | 'fields'; -export interface RetryOptions { - /** - * Maximum number of retry attempts - * - * @default 2 - */ - limit?: number; - /** - * HTTP methods to retry - * - * @default ['get', 'put', 'head', 'delete', 'options', 'trace'] - */ - methods?: Array< - 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace' - >; - /** - * HTTP status codes to retry - * - * @default [408, 413, 429, 500, 502, 503, 504] - */ - statusCodes?: number[]; -} - export interface Config extends Omit< - import('ky').Options, - 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors' + KyOptions, + 'body' | 'headers' | 'method' | 'prefixUrl' | 'throwHttpErrors' >, CoreConfig { - /** - * Base URL for all requests made by this client. - */ baseUrl?: T['baseUrl']; - /** - * Ky instance to use. You can use this option to provide a custom - * ky instance. - */ - ky?: typeof import('ky').default; - /** - * Additional ky-specific options that will be passed directly to ky. - * This allows you to use any ky option not explicitly exposed in the config. - */ - kyOptions?: Omit; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ + ky?: KyInstance; parseAs?: | 'arrayBuffer' | 'auto' @@ -70,28 +29,8 @@ export interface Config | 'json' | 'stream' | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ responseStyle?: ResponseStyle; - /** - * Retry configuration - */ - retry?: RetryOptions; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ throwOnError?: T['throwOnError']; - /** - * Request timeout in milliseconds - * - * @default 10000 - */ - timeout?: number; } export interface RequestOptions<