diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/client.gen.ts new file mode 100644 index 000000000..bf13f1c8e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/client.gen.ts @@ -0,0 +1,167 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios'; +import axios from 'axios'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + let instance: AxiosInstance; + + if (_config.axios && !('Axios' in _config.axios)) { + instance = _config.axios; + } else { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...configWithoutAuth } = _config; + instance = axios.create(configWithoutAuth); + } + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + instance.defaults = { + ...instance.defaults, + ..._config, + // @ts-expect-error + headers: mergeHeaders(instance.defaults.headers, _config.headers), + }; + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + axios: options.axios ?? _config.axios ?? instance, + headers: mergeHeaders(_config.headers, options.headers), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.body = opts.bodySerializer(opts.body); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + try { + // assign Axios here for consistency with fetch + const _axios = opts.axios!; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...optsWithoutAuth } = opts; + const response = await _axios({ + ...optsWithoutAuth, + baseURL: opts.baseURL as string, + data: getValidRequestBody(opts), + headers: opts.headers as RawAxiosRequestHeaders, + // let `paramsSerializer()` handle query params if it exists + params: opts.paramsSerializer ? opts.query : undefined, + url, + }); + + let { data } = response; + + if (opts.responseType === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + ...response, + data: data ?? {}, + }; + } catch (error) { + const e = error as AxiosError; + if (opts.throwOnError) { + throw e; + } + // @ts-expect-error + e.error = e.response?.data ?? {}; + return e; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as Record, + method, + // @ts-expect-error + signal: opts.signal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + instance, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/types.gen.ts new file mode 100644 index 000000000..21789fe0d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosInstance, + AxiosRequestHeaders, + AxiosResponse, + AxiosStatic, + CreateAxiosDefaults, +} from 'axios'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Axios implementation. You can use this option to provide either an + * `AxiosStatic` or an `AxiosInstance`. + * + * @default axios + */ + axios?: AxiosStatic | AxiosInstance; + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Omit, 'axios'>, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + instance: AxiosInstance; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/utils.gen.ts new file mode 100644 index 000000000..37f0f49bf --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/client/utils.gen.ts @@ -0,0 +1,204 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Record; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if (name in options.headers || options.query?.[name]) { + return true; + } + if ( + 'Cookie' in options.headers && + options.headers['Cookie'] && + typeof options.headers['Cookie'] === 'string' + ) { + return options.headers['Cookie'].includes(`${name}=`); + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Record; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': { + const value = `${name}=${token}`; + if ('Cookie' in options.headers && options.headers['Cookie']) { + options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`; + } else { + options.headers['Cookie'] = value; + } + break; + } + case 'header': + default: + options.headers[name] = token; + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + // let `paramsSerializer()` handle query params if it exists + query: !options.paramsSerializer ? options.query : undefined, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +/** + * Special Axios headers keywords allowing to set headers by request method. + */ +export const axiosHeadersKeywords = [ + 'common', + 'delete', + 'get', + 'head', + 'patch', + 'post', + 'put', +] as const; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Record => { + const mergedHeaders: Record = {}; + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = Object.entries(header); + + for (const [key, value] of iterator) { + if ( + axiosHeadersKeywords.includes( + key as (typeof axiosHeadersKeywords)[number], + ) && + typeof value === 'object' + ) { + mergedHeaders[key] = { + ...(mergedHeaders[key] as Record), + ...value, + }; + } else if (value === null) { + delete mergedHeaders[key]; + } else if (Array.isArray(value)) { + for (const v of value) { + // @ts-expect-error + mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string]; + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders[key] = + typeof value === 'object' ? JSON.stringify(value) : (value as string); + } + } + } + return mergedHeaders; +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdk.gen.ts new file mode 100644 index 000000000..e05e58ae3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdk.gen.ts @@ -0,0 +1,472 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + responseType: 'blob', + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-extreme/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/client.gen.ts new file mode 100644 index 000000000..bf13f1c8e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/client.gen.ts @@ -0,0 +1,167 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios'; +import axios from 'axios'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + let instance: AxiosInstance; + + if (_config.axios && !('Axios' in _config.axios)) { + instance = _config.axios; + } else { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...configWithoutAuth } = _config; + instance = axios.create(configWithoutAuth); + } + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + instance.defaults = { + ...instance.defaults, + ..._config, + // @ts-expect-error + headers: mergeHeaders(instance.defaults.headers, _config.headers), + }; + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + axios: options.axios ?? _config.axios ?? instance, + headers: mergeHeaders(_config.headers, options.headers), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.body = opts.bodySerializer(opts.body); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + try { + // assign Axios here for consistency with fetch + const _axios = opts.axios!; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...optsWithoutAuth } = opts; + const response = await _axios({ + ...optsWithoutAuth, + baseURL: opts.baseURL as string, + data: getValidRequestBody(opts), + headers: opts.headers as RawAxiosRequestHeaders, + // let `paramsSerializer()` handle query params if it exists + params: opts.paramsSerializer ? opts.query : undefined, + url, + }); + + let { data } = response; + + if (opts.responseType === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + ...response, + data: data ?? {}, + }; + } catch (error) { + const e = error as AxiosError; + if (opts.throwOnError) { + throw e; + } + // @ts-expect-error + e.error = e.response?.data ?? {}; + return e; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as Record, + method, + // @ts-expect-error + signal: opts.signal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + instance, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/types.gen.ts new file mode 100644 index 000000000..21789fe0d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosInstance, + AxiosRequestHeaders, + AxiosResponse, + AxiosStatic, + CreateAxiosDefaults, +} from 'axios'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Axios implementation. You can use this option to provide either an + * `AxiosStatic` or an `AxiosInstance`. + * + * @default axios + */ + axios?: AxiosStatic | AxiosInstance; + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Omit, 'axios'>, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + instance: AxiosInstance; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/utils.gen.ts new file mode 100644 index 000000000..37f0f49bf --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/client/utils.gen.ts @@ -0,0 +1,204 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Record; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if (name in options.headers || options.query?.[name]) { + return true; + } + if ( + 'Cookie' in options.headers && + options.headers['Cookie'] && + typeof options.headers['Cookie'] === 'string' + ) { + return options.headers['Cookie'].includes(`${name}=`); + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Record; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': { + const value = `${name}=${token}`; + if ('Cookie' in options.headers && options.headers['Cookie']) { + options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`; + } else { + options.headers['Cookie'] = value; + } + break; + } + case 'header': + default: + options.headers[name] = token; + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + // let `paramsSerializer()` handle query params if it exists + query: !options.paramsSerializer ? options.query : undefined, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +/** + * Special Axios headers keywords allowing to set headers by request method. + */ +export const axiosHeadersKeywords = [ + 'common', + 'delete', + 'get', + 'head', + 'patch', + 'post', + 'put', +] as const; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Record => { + const mergedHeaders: Record = {}; + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = Object.entries(header); + + for (const [key, value] of iterator) { + if ( + axiosHeadersKeywords.includes( + key as (typeof axiosHeadersKeywords)[number], + ) && + typeof value === 'object' + ) { + mergedHeaders[key] = { + ...(mergedHeaders[key] as Record), + ...value, + }; + } else if (value === null) { + delete mergedHeaders[key]; + } else if (Array.isArray(value)) { + for (const v of value) { + // @ts-expect-error + mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string]; + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders[key] = + typeof value === 'object' ? JSON.stringify(value) : (value as string); + } + } + } + return mergedHeaders; +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdk.gen.ts new file mode 100644 index 000000000..7bfcdcc6c --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdk.gen.ts @@ -0,0 +1,671 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { zExportData, zPatchApiVbyApiVersionNoTagData, zImportData, zImportResponse, zFooWowData, zApiVVersionODataControllerCountData, zApiVVersionODataControllerCountResponse, zGetApiVbyApiVersionSimpleOperationData, zGetApiVbyApiVersionSimpleOperationResponse, zDeleteCallWithoutParametersAndResponseData, zGetCallWithoutParametersAndResponseData, zHeadCallWithoutParametersAndResponseData, zOptionsCallWithoutParametersAndResponseData, zPatchCallWithoutParametersAndResponseData, zPostCallWithoutParametersAndResponseData, zPutCallWithoutParametersAndResponseData, zDeleteFooData3 as zDeleteFooData, zCallWithDescriptionsData, zDeprecatedCallData, zCallWithParametersData, zCallWithWeirdParameterNamesData, zGetCallWithOptionalParamData, zPostCallWithOptionalParamData, zPostCallWithOptionalParamResponse, zPostApiVbyApiVersionRequestBodyData, zPostApiVbyApiVersionFormDataData, zCallWithDefaultParametersData, zCallWithDefaultOptionalParametersData, zCallToTestOrderOfParamsData, zDuplicateNameData, zDuplicateName2Data, zDuplicateName3Data, zDuplicateName4Data, zCallWithNoContentResponseData, zCallWithNoContentResponseResponse, zCallWithResponseAndNoContentResponseData, zCallWithResponseAndNoContentResponseResponse, zDummyAData, zDummyAResponse, zDummyBData, zDummyBResponse, zCallWithResponseData, zCallWithResponseResponse, zCallWithDuplicateResponsesData, zCallWithDuplicateResponsesResponse, zCallWithResponsesData, zCallWithResponsesResponse, zCollectionFormatData, zTypesData, zTypesResponse, zUploadFileData, zUploadFileResponse, zFileResponseData, zFileResponseResponse, zComplexTypesData, zComplexTypesResponse, zMultipartResponseData, zMultipartResponseResponse, zMultipartRequestData, zComplexParamsData, zComplexParamsResponse, zCallWithResultFromHeaderData, zTestErrorCodeData, zNonAsciiæøåÆøÅöôêÊ字符串Data, zNonAsciiæøåÆøÅöôêÊ字符串Response, zPutWithFormUrlEncodedData } from './zod.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + requestValidator: async (data) => { + return await zExportData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchApiVbyApiVersionNoTagData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + requestValidator: async (data) => { + return await zImportData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zImportResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + requestValidator: async (data) => { + return await zFooWowData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + requestValidator: async (data) => { + return await zApiVVersionODataControllerCountData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zApiVVersionODataControllerCountResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + requestValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zHeadCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zOptionsCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPutCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteFooData.parseAsync(data); + }, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDescriptionsData.parseAsync(data); + }, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + requestValidator: async (data) => { + return await zDeprecatedCallData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithWeirdParameterNamesData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithOptionalParamData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithOptionalParamData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zPostCallWithOptionalParamResponse.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionRequestBodyData.parseAsync(data); + }, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionFormDataData.parseAsync(data); + }, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultOptionalParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallToTestOrderOfParamsData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateNameData.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName2Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName3Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName4Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + requestValidator: async (data) => { + return await zDummyAData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zDummyAResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + requestValidator: async (data) => { + return await zDummyBData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyBResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDuplicateResponsesData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zCallWithDuplicateResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponsesData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zCallWithResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + requestValidator: async (data) => { + return await zCollectionFormatData.parseAsync(data); + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + requestValidator: async (data) => { + return await zTypesData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + requestValidator: async (data) => { + return await zUploadFileData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zUploadFileResponse.parseAsync(data); + }, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zFileResponseData.parseAsync(data); + }, + responseType: 'blob', + responseValidator: async (data) => { + return await zFileResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexTypesData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zComplexTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zMultipartResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartRequestData.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexParamsData.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zComplexParamsResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResultFromHeaderData.parseAsync(data); + }, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + requestValidator: async (data) => { + return await zTestErrorCodeData.parseAsync(data); + }, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + requestValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Data.parseAsync(data); + }, + responseType: 'json', + responseValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Response.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + requestValidator: async (data) => { + return await zPutWithFormUrlEncodedData.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/zod.gen.ts new file mode 100644 index 000000000..a08796446 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing-zod/zod.gen.ts @@ -0,0 +1,1790 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +/** + * Model with number-only name + */ +export const z400 = z.string(); + +export const zExternalSharedExternalSharedModel = z.object({ + id: z.string(), + name: z.optional(z.string()) +}); + +/** + * External ref to shared model (A) + */ +export const zExternalRefA = zExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export const zExternalRefB = zExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCamelCaseCommentWithBreaks = z.int(); + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCommentWithBreaks = z.int(); + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export const zCommentWithBackticks = z.int(); + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export const zCommentWithBackticksAndQuotes = z.int(); + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export const zCommentWithSlashes = z.int(); + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export const zCommentWithExpressionPlaceholders = z.int(); + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export const zCommentWithQuotes = z.int(); + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export const zCommentWithReservedCharacters = z.int(); + +/** + * This is a simple number + */ +export const zSimpleInteger = z.int(); + +/** + * This is a simple boolean + */ +export const zSimpleBoolean = z.boolean(); + +/** + * This is a simple string + */ +export const zSimpleString = z.string(); + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); + +/** + * This is a simple file + */ +export const zSimpleFile = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithString = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a simple reference + */ +export const zSimpleReference = zModelWithString; + +/** + * This is a simple string + */ +export const zSimpleStringWithPattern = z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + z.null() +]); + +/** + * This is a simple enum with strings + */ +export const zEnumWithStrings = z.enum([ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串' +]); + +export const zEnumWithReplacedCharacters = z.enum([ + "'Single Quote'", + '"Double Quotes"', + 'øæåôöØÆÅÔÖ字符串', + '' +]); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithNumbers = z.unknown(); + +/** + * Success=1,Warning=2,Error=3 + */ +export const zEnumFromDescription = z.number(); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithExtensions = z.unknown(); + +export const zEnumWithXEnumNames = z.unknown(); + +/** + * This is a simple array with numbers + */ +export const zArrayWithNumbers = z.array(z.int()); + +/** + * This is a simple array with booleans + */ +export const zArrayWithBooleans = z.array(z.boolean()); + +/** + * This is a simple array with strings + */ +export const zArrayWithStrings = z.array(z.string()).default(['test']); + +/** + * This is a simple array with references + */ +export const zArrayWithReferences = z.array(zModelWithString); + +/** + * This is a simple array containing an array + */ +export const zArrayWithArray = z.array(z.array(zModelWithString)); + +/** + * This is a simple array with properties + */ +export const zArrayWithProperties = z.array(z.object({ + '16x16': z.optional(zCamelCaseCommentWithBreaks), + bar: z.optional(z.string()) +})); + +/** + * This is a simple array with any of properties + */ +export const zArrayWithAnyOfProperties = z.array(z.union([ + z.object({ + foo: z.optional(z.string()).default('test') + }), + z.object({ + bar: z.optional(z.string()) + }) +])); + +export const zAnyOfAnyAndNull = z.object({ + data: z.optional(z.union([ + z.unknown(), + z.null() + ])) +}); + +/** + * This is a simple array with any of properties + */ +export const zAnyOfArrays = z.object({ + results: z.optional(z.array(z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.object({ + bar: z.optional(z.string()) + }) + ]))) +}); + +/** + * This is a string dictionary + */ +export const zDictionaryWithString = z.record(z.string(), z.string()); + +export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ + foo: z.optional(z.number()), + bar: z.optional(z.boolean()) +}); + +/** + * This is a string reference + */ +export const zDictionaryWithReference = z.record(z.string(), zModelWithString); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); + +/** + * This is a string dictionary + */ +export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithProperties = z.record(z.string(), z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) +})); + +/** + * This is a model with one number property + */ +export const zModelWithInteger = z.object({ + prop: z.optional(z.int()) +}); + +/** + * This is a model with one boolean property + */ +export const zModelWithBoolean = z.object({ + prop: z.optional(z.boolean()) +}); + +/** + * This is a model with one string property + */ +export const zModelWithStringError = z.object({ + prop: z.optional(z.string()) +}); + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export const zModelFromZendesk = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithNullableString = z.object({ + nullableProp1: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp1: z.union([ + z.string(), + z.null() + ]), + nullableProp2: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp2: z.union([ + z.string(), + z.null() + ]), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnum = z.object({ + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])), + statusCode: z.optional(z.enum([ + '100', + '200 FOO', + '300 FOO_BAR', + '400 foo-bar', + '500 foo.bar', + '600 foo&bar' + ])), + bool: z.optional(z.unknown()) +}); + +/** + * This is a model with one enum with escaped name + */ +export const zModelWithEnumWithHyphen = z.object({ + 'foo-bar-baz-qux': z.optional(z.enum([ + '3.0' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnumFromDescription = z.object({ + test: z.optional(z.int()) +}); + +/** + * This is a model with nested enums + */ +export const zModelWithNestedEnums = z.object({ + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), + arrayWithEnum: z.optional(z.array(z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + arrayWithDescription: z.optional(z.array(z.int())), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one nested property + */ +export const zModelWithProperties = z.object({ + required: z.string(), + requiredAndReadOnly: z.string().readonly(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()), + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()) +}); + +/** + * This is a model with one property containing a reference + */ +export const zModelWithReference = z.object({ + prop: z.optional(zModelWithProperties) +}); + +export const zModelWithReadOnlyAndWriteOnly = z.object({ + foo: z.string(), + bar: z.string().readonly() +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArray = z.object({ + prop: z.optional(z.array(zModelWithString)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing a dictionary + */ +export const zModelWithDictionary = z.object({ + prop: z.optional(z.record(z.string(), z.string())) +}); + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export const zDeprecatedModel = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a model with one property containing a circular reference + */ +export const zModelWithCircularReference = z.object({ + get prop(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zModelWithCircularReference; + })); + } +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * Circle + */ +export const zModelCircle = z.object({ + kind: z.string(), + radius: z.optional(z.number()) +}); + +/** + * Square + */ +export const zModelSquare = z.object({ + kind: z.string(), + sideLength: z.optional(z.number()) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfDiscriminator = z.union([ + z.object({ + kind: z.literal('circle') + }).and(zModelCircle), + z.object({ + kind: z.literal('square') + }).and(zModelSquare) +]); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithAnyOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * This is a model with nested 'any of' property with a type null + */ +export const zCompositionWithNestedAnyAndTypeNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + zModelWithDictionary, + z.null() + ])), + z.array(z.union([ + zModelWithArray, + z.null() + ])) + ])) +}); + +export const z3eNum1Период = z.enum([ + 'Bird', + 'Dog' +]); + +export const zConstValue = z.literal('ConstValue'); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithNestedAnyOfAndNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + z3eNum1Период, + zConstValue + ])), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a model that contains a simple dictionary within composition + */ +export const zCompositionWithOneOfAndSimpleDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.number()) + ])) +}); + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.boolean())) + ])) +}); + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.union([ + z.number(), + z.string() + ]))) + ])) +}); + +/** + * This is a model with one property with a 'all of' relationship + */ +export const zCompositionWithAllOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a base model with two simple optional properties + */ +export const zCompositionBaseModel = z.object({ + firstName: z.optional(z.string()), + lastname: z.optional(z.string()) +}); + +/** + * This is a model that extends the base model + */ +export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ + age: z.number(), + firstName: z.string(), + lastname: z.string() +})); + +/** + * This is a model with one nested property + */ +export const zModelWithNestedProperties = z.object({ + first: z.union([ + z.object({ + second: z.union([ + z.object({ + third: z.union([ + z.string().readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() +}); + +/** + * This is a model with duplicated properties + */ +export const zModelWithDuplicateProperties = z.object({ + prop: z.optional(zModelWithString) +}); + +/** + * This is a model with ordered properties + */ +export const zModelWithOrderedProperties = z.object({ + zebra: z.optional(z.string()), + apple: z.optional(z.string()), + hawaii: z.optional(z.string()) +}); + +/** + * This is a model with duplicated imports + */ +export const zModelWithDuplicateImports = z.object({ + propA: z.optional(zModelWithString), + propB: z.optional(zModelWithString), + propC: z.optional(zModelWithString) +}); + +/** + * This is a model that extends another model + */ +export const zModelThatExtends = zModelWithString.and(z.object({ + propExtendsA: z.optional(z.string()), + propExtendsB: z.optional(zModelWithString) +})); + +/** + * This is a model that extends another model + */ +export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ + propExtendsC: z.optional(z.string()), + propExtendsD: z.optional(zModelWithString) +})); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPattern = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + enabled: z.optional(z.boolean().readonly()), + modified: z.optional(z.iso.datetime().readonly()), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFile = z.object({ + id: z.optional(z.string().min(1).readonly()), + updated_at: z.optional(z.iso.datetime().readonly()), + created_at: z.optional(z.iso.datetime().readonly()), + mime: z.string().min(1).max(24), + file: z.optional(z.url().readonly()) +}); + +export const zDefault = z.object({ + name: z.optional(z.string()) +}); + +export const zPageable = z.object({ + page: z.optional(z.int().gte(0)).default(0), + size: z.optional(z.int().gte(1)), + sort: z.optional(z.array(z.string())) +}); + +/** + * This is a free-form object without additionalProperties. + */ +export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: true. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: {}. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); + +export const zModelWithConst = z.object({ + String: z.optional(z.literal('String')), + number: z.optional(z.literal(0)), + null: z.optional(z.null()), + withType: z.optional(z.literal('Some string')) +}); + +/** + * This is a model with one property and additionalProperties: true + */ +export const zModelWithAdditionalPropertiesEqTrue = z.object({ + prop: z.optional(z.string()) +}); + +export const zNestedAnyOfArraysNullable = z.object({ + nullableArray: z.optional(z.union([ + z.array(z.union([ + z.string(), + z.boolean() + ])), + z.null() + ])) +}); + +/** + * This is a reusable parameter + */ +export const zSimpleParameter = z.unknown(); + +export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ + z.object({ + foo: zSimpleParameter + }), + z.object({ + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 + }) +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * An object that can be null + */ +export const zNullableObject = z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.null() +]).default(null); + +/** + * Some % character + */ +export const zCharactersInDescription = z.string(); + +export const zModelWithNullableObject = z.object({ + data: z.optional(zNullableObject) +}); + +export const zModelWithOneOfEnum = z.union([ + z.object({ + foo: z.enum([ + 'Bar' + ]) + }), + z.object({ + foo: z.enum([ + 'Baz' + ]) + }), + z.object({ + foo: z.enum([ + 'Qux' + ]) + }), + z.object({ + content: z.iso.datetime(), + foo: z.enum([ + 'Quux' + ]) + }), + z.object({ + content: z.tuple([ + z.iso.datetime(), + z.string() + ]), + foo: z.enum([ + 'Corge' + ]) + }) +]); + +export const zModelWithNestedArrayEnumsDataFoo = z.enum([ + 'foo', + 'bar' +]); + +export const zModelWithNestedArrayEnumsDataBar = z.enum([ + 'baz', + 'qux' +]); + +export const zModelWithNestedArrayEnumsData = z.object({ + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) +}); + +export const zModelWithNestedArrayEnums = z.object({ + array_strings: z.optional(z.array(z.string())), + data: z.optional(zModelWithNestedArrayEnumsData) +}); + +export const zModelWithNestedCompositionEnums = z.object({ + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) +}); + +export const zModelWithConstantSizeArray = z.tuple([ + z.number(), + z.number() +]); + +export const zModelWithAnyOfConstantSizeArray = z.tuple([ + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]) +]); + +export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ + zModelWithInteger, + z.union([ + z.number(), + z.string() + ]), + z.string() +]); + +export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]) +]); + +/** + * Model with restricted keyword name + */ +export const zImport = z.string(); + +export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ + z.union([ + z.number(), + zImport + ]), + z.union([ + z.number(), + zImport + ]) +]); + +export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ + z.intersection(z.number(), z.string()), + z.intersection(z.number(), z.string()) +]); + +export const zModelWithNumericEnumUnion = z.object({ + value: z.optional(z.unknown()) +}); + +/** + * Some description with `back ticks` + */ +export const zModelWithBackticksInDescription = z.object({ + template: z.optional(z.string()) +}); + +export const zModelWithOneOfAndProperties = z.intersection(z.union([ + zSimpleParameter, + zNonAsciiStringæøåÆøÅöôêÊ字符串 +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * Model used to test deduplication strategy (unused) + */ +export const zParameterSimpleParameterUnused = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse2 = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData2 = z.string(); + +export const zSchemaWithFormRestrictedKeys = z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()), + object: z.optional(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + })), + array: z.optional(z.array(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + }))) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ + resourceVersion: z.optional(z.string()), + uid: z.optional(z.string()) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) +}); + +export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) +})); + +export const zAdditionalPropertiesIntegerIssue = z.object({ + value: z.int() +}); + +export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemString = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()) +}); + +export const zOneOfAllOfIssue = z.union([ + z.intersection(z.union([ + zConstValue, + zGenericSchemaDuplicateIssue1SystemBoolean + ]), z3eNum1Период), + zGenericSchemaDuplicateIssue1SystemString +]); + +/** + * This is a model with one nested property + */ +export const zModelWithPropertiesWritable = z.object({ + required: z.string(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()) +}); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPatternWritable = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFileWritable = z.object({ + mime: z.string().min(1).max(24) +}); + +export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ + foo: z.string(), + baz: z.string() +}); + +export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zGenericSchemaDuplicateIssue1SystemBooleanWritable = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemStringWritable = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])) +}); + +/** + * Parameter with illegal characters + */ +export const zXFooBar = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleRequestBody = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleFormData = zModelWithString; + +export const zExportData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchApiVbyApiVersionNoTagData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportData = z.object({ + body: z.union([ + zModelWithReadOnlyAndWriteOnlyWritable, + zModelWithArrayReadOnlyAndWriteOnly + ]), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportResponse = z.union([ + zModelFromZendesk, + zModelWithReadOnlyAndWriteOnly +]); + +export const zFooWowData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zApiVVersionODataControllerCountData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; + +export const zGetApiVbyApiVersionSimpleOperationData = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.union([ + z.string(), + z.uuid() + ]) + }), + query: z.optional(z.never()) +}); + +/** + * Response is a simple number + */ +export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); + +export const zDeleteCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zGetCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zHeadCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zOptionsCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPostCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPutCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDeleteFooData3 = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.string(), + BarParam: z.string() + }), + query: z.optional(z.never()), + headers: z.object({ + 'x-Foo-Bar': zModelWithString + }) +}); + +export const zCallWithDescriptionsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterWithBreaks: z.optional(z.string()), + parameterWithBackticks: z.optional(z.string()), + parameterWithSlashes: z.optional(z.string()), + parameterWithExpressionPlaceholders: z.optional(z.string()), + parameterWithQuotes: z.optional(z.string()), + parameterWithReservedCharacters: z.optional(z.string()) + })) +}); + +export const zDeprecatedCallData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()), + headers: z.object({ + parameter: z.union([ + zDeprecatedModel, + z.null() + ]) + }) +}); + +export const zCallWithParametersData = z.object({ + body: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + path: z.object({ + parameterPath: z.union([ + z.string(), + z.null() + ]), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFoo), + foo_all_of_enum: zModelWithNestedArrayEnumsDataFoo, + cursor: z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + parameterHeader: z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zCallWithWeirdParameterNamesData = z.object({ + body: z.union([ + zModelWithString, + z.null() + ]), + path: z.object({ + 'parameter.path.1': z.optional(z.string()), + 'parameter-path-2': z.optional(z.string()), + 'PARAMETER-PATH-3': z.optional(z.string()), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + default: z.optional(z.string()), + 'parameter-query': z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + 'parameter.header': z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zGetCallWithOptionalParamData = z.object({ + body: zModelWithOneOfEnum, + path: z.optional(z.never()), + query: z.optional(z.object({ + page: z.optional(z.number()) + })) +}); + +export const zPostCallWithOptionalParamData = z.object({ + body: z.optional(z.object({ + offset: z.optional(z.union([ + z.number(), + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.object({ + parameter: zPageable + }) +}); + +export const zPostCallWithOptionalParamResponse = z.union([ + z.number(), + z.void() +]); + +export const zPostApiVbyApiVersionRequestBodyData = z.object({ + body: z.optional(zSimpleRequestBody), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zPostApiVbyApiVersionFormDataData = z.object({ + body: z.optional(zSimpleFormData), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zCallWithDefaultParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.union([ + z.string().default('Hello World!'), + z.null() + ])).default('Hello World!'), + parameterNumber: z.optional(z.union([ + z.number().default(123), + z.null() + ])).default(123), + parameterBoolean: z.optional(z.union([ + z.boolean().default(true), + z.null() + ])).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })) +}); + +export const zCallWithDefaultOptionalParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.string()).default('Hello World!'), + parameterNumber: z.optional(z.number()).default(123), + parameterBoolean: z.optional(z.boolean()).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(zModelWithString) + })) +}); + +export const zCallToTestOrderOfParamsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterOptionalStringWithDefault: z.optional(z.string()).default('Hello World!'), + parameterOptionalStringWithEmptyDefault: z.optional(z.string()).default(''), + parameterOptionalStringWithNoDefault: z.optional(z.string()), + parameterStringWithDefault: z.string().default('Hello World!'), + parameterStringWithEmptyDefault: z.string().default(''), + parameterStringWithNoDefault: z.string(), + parameterStringNullableWithNoDefault: z.optional(z.union([ + z.string(), + z.null() + ])), + parameterStringNullableWithDefault: z.optional(z.union([ + z.string(), + z.null() + ])).default(null) + }) +}); + +export const zDuplicateNameData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName2Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName3Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName4Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zCallWithNoContentResponseResponse = z.void(); + +export const zCallWithResponseAndNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseAndNoContentResponseResponse = z.union([ + z.number(), + z.void() +]); + +export const zDummyAData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDummyAResponse = z400; + +export const zDummyBData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zDummyBResponse = z.void(); + +export const zCallWithResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseResponse = zImport; + +export const zCallWithDuplicateResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithDuplicateResponsesResponse = z.union([ + zModelWithBoolean.and(zModelWithInteger), + zModelWithString +]); + +export const zCallWithResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponsesResponse = z.union([ + z.object({ + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()), + value: z.optional(z.array(zModelWithString).readonly()) + }), + zModelThatExtends, + zModelThatExtendsExtends +]); + +export const zCollectionFormatData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterArrayCSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArraySSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayTSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayPipes: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayMulti: z.union([ + z.array(z.string()), + z.null() + ]) + }) +}); + +export const zTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.object({ + id: z.optional(z.int()) + })), + query: z.object({ + parameterNumber: z.number().default(123), + parameterString: z.union([ + z.string().default('default'), + z.null() + ]).default('default'), + parameterBoolean: z.union([ + z.boolean().default(true), + z.null() + ]).default(true), + parameterObject: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]).default(null), + parameterArray: z.union([ + z.array(z.string()), + z.null() + ]), + parameterDictionary: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + parameterEnum: z.union([ + z.literal('Success'), + z.literal('Warning'), + z.literal('Error'), + z.null() + ]) + }) +}); + +export const zTypesResponse = z.union([ + z.number(), + z.string(), + z.boolean(), + z.record(z.string(), z.unknown()) +]); + +export const zUploadFileData = z.object({ + body: z.string(), + path: z.object({ + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.optional(z.never()) +}); + +export const zUploadFileResponse = z.boolean(); + +export const zFileResponseData = z.object({ + body: z.optional(z.never()), + path: z.object({ + id: z.string(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zFileResponseResponse = z.string(); + +export const zComplexTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterObject: z.object({ + first: z.optional(z.object({ + second: z.optional(z.object({ + third: z.optional(z.string()) + })) + })) + }), + parameterReference: zModelWithString + }) +}); + +/** + * Successful response + */ +export const zComplexTypesResponse = z.array(zModelWithString); + +export const zMultipartResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * OK + */ +export const zMultipartResponseResponse = z.object({ + file: z.optional(z.string()), + metadata: z.optional(z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) + })) +}); + +export const zMultipartRequestData = z.object({ + body: z.optional(z.object({ + content: z.optional(z.string()), + data: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zComplexParamsData = z.object({ + body: z.optional(z.object({ + key: z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), + z.null() + ]).readonly(), + name: z.union([ + z.string().max(255), + z.null() + ]), + enabled: z.optional(z.boolean()).default(true), + type: z.enum([ + 'Monkey', + 'Horse', + 'Bird' + ]), + listOfModels: z.optional(z.union([ + z.array(zModelWithString), + z.null() + ])), + listOfStrings: z.optional(z.union([ + z.array(z.string()), + z.null() + ])), + parameters: z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ]), + user: z.optional(z.object({ + id: z.optional(z.int().readonly()), + name: z.optional(z.union([ + z.string().readonly(), + z.null() + ]).readonly()) + }).readonly()) + })), + path: z.object({ + id: z.int(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zComplexParamsResponse = zModelWithString; + +export const zCallWithResultFromHeaderData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zTestErrorCodeData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + status: z.int() + }) +}); + +export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() + }) +}); + +/** + * Successful response + */ +export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); + +export const zPutWithFormUrlEncodedData = z.object({ + body: zArrayWithStrings, + path: z.optional(z.never()), + query: z.optional(z.never()) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/client.gen.ts new file mode 100644 index 000000000..bf13f1c8e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/client.gen.ts @@ -0,0 +1,167 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios'; +import axios from 'axios'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + let instance: AxiosInstance; + + if (_config.axios && !('Axios' in _config.axios)) { + instance = _config.axios; + } else { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...configWithoutAuth } = _config; + instance = axios.create(configWithoutAuth); + } + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + instance.defaults = { + ...instance.defaults, + ..._config, + // @ts-expect-error + headers: mergeHeaders(instance.defaults.headers, _config.headers), + }; + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + axios: options.axios ?? _config.axios ?? instance, + headers: mergeHeaders(_config.headers, options.headers), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.body = opts.bodySerializer(opts.body); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + try { + // assign Axios here for consistency with fetch + const _axios = opts.axios!; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { auth, ...optsWithoutAuth } = opts; + const response = await _axios({ + ...optsWithoutAuth, + baseURL: opts.baseURL as string, + data: getValidRequestBody(opts), + headers: opts.headers as RawAxiosRequestHeaders, + // let `paramsSerializer()` handle query params if it exists + params: opts.paramsSerializer ? opts.query : undefined, + url, + }); + + let { data } = response; + + if (opts.responseType === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + ...response, + data: data ?? {}, + }; + } catch (error) { + const e = error as AxiosError; + if (opts.throwOnError) { + throw e; + } + // @ts-expect-error + e.error = e.response?.data ?? {}; + return e; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as Record, + method, + // @ts-expect-error + signal: opts.signal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + instance, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/types.gen.ts new file mode 100644 index 000000000..21789fe0d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AxiosError, + AxiosInstance, + AxiosRequestHeaders, + AxiosResponse, + AxiosStatic, + CreateAxiosDefaults, +} from 'axios'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Axios implementation. You can use this option to provide either an + * `AxiosStatic` or an `AxiosInstance`. + * + * @default axios + */ + axios?: AxiosStatic | AxiosInstance; + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | AxiosRequestHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ClientOptions { + baseURL?: string; + throwOnError?: boolean; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise< + AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > + > + : Promise< + | (AxiosResponse< + TData extends Record ? TData[keyof TData] : TData + > & { error: undefined }) + | (AxiosError< + TError extends Record ? TError[keyof TError] : TError + > & { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + }) + >; + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Omit, 'axios'>, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + instance: AxiosInstance; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/utils.gen.ts new file mode 100644 index 000000000..37f0f49bf --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/client/utils.gen.ts @@ -0,0 +1,204 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Record; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if (name in options.headers || options.query?.[name]) { + return true; + } + if ( + 'Cookie' in options.headers && + options.headers['Cookie'] && + typeof options.headers['Cookie'] === 'string' + ) { + return options.headers['Cookie'].includes(`${name}=`); + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Record; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': { + const value = `${name}=${token}`; + if ('Cookie' in options.headers && options.headers['Cookie']) { + options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`; + } else { + options.headers['Cookie'] = value; + } + break; + } + case 'header': + default: + options.headers[name] = token; + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + // let `paramsSerializer()` handle query params if it exists + query: !options.paramsSerializer ? options.query : undefined, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +/** + * Special Axios headers keywords allowing to set headers by request method. + */ +export const axiosHeadersKeywords = [ + 'common', + 'delete', + 'get', + 'head', + 'patch', + 'post', + 'put', +] as const; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Record => { + const mergedHeaders: Record = {}; + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = Object.entries(header); + + for (const [key, value] of iterator) { + if ( + axiosHeadersKeywords.includes( + key as (typeof axiosHeadersKeywords)[number], + ) && + typeof value === 'object' + ) { + mergedHeaders[key] = { + ...(mergedHeaders[key] as Record), + ...value, + }; + } else if (value === null) { + delete mergedHeaders[key]; + } else if (Array.isArray(value)) { + for (const v of value) { + // @ts-expect-error + mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string]; + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders[key] = + typeof value === 'object' ? JSON.stringify(value) : (value as string); + } + } + } + return mergedHeaders; +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdk.gen.ts new file mode 100644 index 000000000..e05e58ae3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdk.gen.ts @@ -0,0 +1,472 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + responseType: 'blob', + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + responseType: 'json', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-preserve-wire-casing/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/client.gen.ts index 17fc6d73c..ebdbe5564 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60f..c703e9ed4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/client.gen.ts new file mode 100644 index 000000000..b6d0dff2d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/client.gen.ts @@ -0,0 +1,272 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + 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-fetch/sdk-preserve-wire-casing-extreme/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/types.gen.ts new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/utils.gen.ts new file mode 100644 index 000000000..b4bcc4d19 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/client/utils.gen.ts @@ -0,0 +1,331 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdk.gen.ts new file mode 100644 index 000000000..b5f8b7d55 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-extreme/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/client.gen.ts new file mode 100644 index 000000000..b6d0dff2d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/client.gen.ts @@ -0,0 +1,272 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + 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-fetch/sdk-preserve-wire-casing-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/types.gen.ts new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/utils.gen.ts new file mode 100644 index 000000000..b4bcc4d19 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/client/utils.gen.ts @@ -0,0 +1,331 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdk.gen.ts new file mode 100644 index 000000000..bf18a40f8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdk.gen.ts @@ -0,0 +1,657 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { zExportData, zPatchApiVbyApiVersionNoTagData, zImportData, zImportResponse, zFooWowData, zApiVVersionODataControllerCountData, zApiVVersionODataControllerCountResponse, zGetApiVbyApiVersionSimpleOperationData, zGetApiVbyApiVersionSimpleOperationResponse, zDeleteCallWithoutParametersAndResponseData, zGetCallWithoutParametersAndResponseData, zHeadCallWithoutParametersAndResponseData, zOptionsCallWithoutParametersAndResponseData, zPatchCallWithoutParametersAndResponseData, zPostCallWithoutParametersAndResponseData, zPutCallWithoutParametersAndResponseData, zDeleteFooData3 as zDeleteFooData, zCallWithDescriptionsData, zDeprecatedCallData, zCallWithParametersData, zCallWithWeirdParameterNamesData, zGetCallWithOptionalParamData, zPostCallWithOptionalParamData, zPostCallWithOptionalParamResponse, zPostApiVbyApiVersionRequestBodyData, zPostApiVbyApiVersionFormDataData, zCallWithDefaultParametersData, zCallWithDefaultOptionalParametersData, zCallToTestOrderOfParamsData, zDuplicateNameData, zDuplicateName2Data, zDuplicateName3Data, zDuplicateName4Data, zCallWithNoContentResponseData, zCallWithNoContentResponseResponse, zCallWithResponseAndNoContentResponseData, zCallWithResponseAndNoContentResponseResponse, zDummyAData, zDummyAResponse, zDummyBData, zDummyBResponse, zCallWithResponseData, zCallWithResponseResponse, zCallWithDuplicateResponsesData, zCallWithDuplicateResponsesResponse, zCallWithResponsesData, zCallWithResponsesResponse, zCollectionFormatData, zTypesData, zTypesResponse, zUploadFileData, zUploadFileResponse, zFileResponseData, zFileResponseResponse, zComplexTypesData, zComplexTypesResponse, zMultipartResponseData, zMultipartResponseResponse, zMultipartRequestData, zComplexParamsData, zComplexParamsResponse, zCallWithResultFromHeaderData, zTestErrorCodeData, zNonAsciiæøåÆøÅöôêÊ字符串Data, zNonAsciiæøåÆøÅöôêÊ字符串Response, zPutWithFormUrlEncodedData } from './zod.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + requestValidator: async (data) => { + return await zExportData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchApiVbyApiVersionNoTagData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + requestValidator: async (data) => { + return await zImportData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zImportResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + requestValidator: async (data) => { + return await zFooWowData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + requestValidator: async (data) => { + return await zApiVVersionODataControllerCountData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zApiVVersionODataControllerCountResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + requestValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zHeadCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zOptionsCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPutCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteFooData.parseAsync(data); + }, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDescriptionsData.parseAsync(data); + }, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + requestValidator: async (data) => { + return await zDeprecatedCallData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithWeirdParameterNamesData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithOptionalParamData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithOptionalParamData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zPostCallWithOptionalParamResponse.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionRequestBodyData.parseAsync(data); + }, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionFormDataData.parseAsync(data); + }, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultOptionalParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallToTestOrderOfParamsData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateNameData.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName2Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName3Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName4Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + requestValidator: async (data) => { + return await zDummyAData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyAResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + requestValidator: async (data) => { + return await zDummyBData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyBResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDuplicateResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithDuplicateResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + requestValidator: async (data) => { + return await zCollectionFormatData.parseAsync(data); + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + requestValidator: async (data) => { + return await zTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + requestValidator: async (data) => { + return await zUploadFileData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zUploadFileResponse.parseAsync(data); + }, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zFileResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zFileResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zMultipartResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartRequestData.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexParamsData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexParamsResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResultFromHeaderData.parseAsync(data); + }, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + requestValidator: async (data) => { + return await zTestErrorCodeData.parseAsync(data); + }, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + requestValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Data.parseAsync(data); + }, + responseValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Response.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + requestValidator: async (data) => { + return await zPutWithFormUrlEncodedData.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/zod.gen.ts new file mode 100644 index 000000000..a08796446 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing-zod/zod.gen.ts @@ -0,0 +1,1790 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +/** + * Model with number-only name + */ +export const z400 = z.string(); + +export const zExternalSharedExternalSharedModel = z.object({ + id: z.string(), + name: z.optional(z.string()) +}); + +/** + * External ref to shared model (A) + */ +export const zExternalRefA = zExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export const zExternalRefB = zExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCamelCaseCommentWithBreaks = z.int(); + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCommentWithBreaks = z.int(); + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export const zCommentWithBackticks = z.int(); + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export const zCommentWithBackticksAndQuotes = z.int(); + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export const zCommentWithSlashes = z.int(); + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export const zCommentWithExpressionPlaceholders = z.int(); + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export const zCommentWithQuotes = z.int(); + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export const zCommentWithReservedCharacters = z.int(); + +/** + * This is a simple number + */ +export const zSimpleInteger = z.int(); + +/** + * This is a simple boolean + */ +export const zSimpleBoolean = z.boolean(); + +/** + * This is a simple string + */ +export const zSimpleString = z.string(); + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); + +/** + * This is a simple file + */ +export const zSimpleFile = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithString = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a simple reference + */ +export const zSimpleReference = zModelWithString; + +/** + * This is a simple string + */ +export const zSimpleStringWithPattern = z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + z.null() +]); + +/** + * This is a simple enum with strings + */ +export const zEnumWithStrings = z.enum([ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串' +]); + +export const zEnumWithReplacedCharacters = z.enum([ + "'Single Quote'", + '"Double Quotes"', + 'øæåôöØÆÅÔÖ字符串', + '' +]); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithNumbers = z.unknown(); + +/** + * Success=1,Warning=2,Error=3 + */ +export const zEnumFromDescription = z.number(); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithExtensions = z.unknown(); + +export const zEnumWithXEnumNames = z.unknown(); + +/** + * This is a simple array with numbers + */ +export const zArrayWithNumbers = z.array(z.int()); + +/** + * This is a simple array with booleans + */ +export const zArrayWithBooleans = z.array(z.boolean()); + +/** + * This is a simple array with strings + */ +export const zArrayWithStrings = z.array(z.string()).default(['test']); + +/** + * This is a simple array with references + */ +export const zArrayWithReferences = z.array(zModelWithString); + +/** + * This is a simple array containing an array + */ +export const zArrayWithArray = z.array(z.array(zModelWithString)); + +/** + * This is a simple array with properties + */ +export const zArrayWithProperties = z.array(z.object({ + '16x16': z.optional(zCamelCaseCommentWithBreaks), + bar: z.optional(z.string()) +})); + +/** + * This is a simple array with any of properties + */ +export const zArrayWithAnyOfProperties = z.array(z.union([ + z.object({ + foo: z.optional(z.string()).default('test') + }), + z.object({ + bar: z.optional(z.string()) + }) +])); + +export const zAnyOfAnyAndNull = z.object({ + data: z.optional(z.union([ + z.unknown(), + z.null() + ])) +}); + +/** + * This is a simple array with any of properties + */ +export const zAnyOfArrays = z.object({ + results: z.optional(z.array(z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.object({ + bar: z.optional(z.string()) + }) + ]))) +}); + +/** + * This is a string dictionary + */ +export const zDictionaryWithString = z.record(z.string(), z.string()); + +export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ + foo: z.optional(z.number()), + bar: z.optional(z.boolean()) +}); + +/** + * This is a string reference + */ +export const zDictionaryWithReference = z.record(z.string(), zModelWithString); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); + +/** + * This is a string dictionary + */ +export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithProperties = z.record(z.string(), z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) +})); + +/** + * This is a model with one number property + */ +export const zModelWithInteger = z.object({ + prop: z.optional(z.int()) +}); + +/** + * This is a model with one boolean property + */ +export const zModelWithBoolean = z.object({ + prop: z.optional(z.boolean()) +}); + +/** + * This is a model with one string property + */ +export const zModelWithStringError = z.object({ + prop: z.optional(z.string()) +}); + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export const zModelFromZendesk = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithNullableString = z.object({ + nullableProp1: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp1: z.union([ + z.string(), + z.null() + ]), + nullableProp2: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp2: z.union([ + z.string(), + z.null() + ]), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnum = z.object({ + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])), + statusCode: z.optional(z.enum([ + '100', + '200 FOO', + '300 FOO_BAR', + '400 foo-bar', + '500 foo.bar', + '600 foo&bar' + ])), + bool: z.optional(z.unknown()) +}); + +/** + * This is a model with one enum with escaped name + */ +export const zModelWithEnumWithHyphen = z.object({ + 'foo-bar-baz-qux': z.optional(z.enum([ + '3.0' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnumFromDescription = z.object({ + test: z.optional(z.int()) +}); + +/** + * This is a model with nested enums + */ +export const zModelWithNestedEnums = z.object({ + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), + arrayWithEnum: z.optional(z.array(z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + arrayWithDescription: z.optional(z.array(z.int())), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one nested property + */ +export const zModelWithProperties = z.object({ + required: z.string(), + requiredAndReadOnly: z.string().readonly(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()), + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()) +}); + +/** + * This is a model with one property containing a reference + */ +export const zModelWithReference = z.object({ + prop: z.optional(zModelWithProperties) +}); + +export const zModelWithReadOnlyAndWriteOnly = z.object({ + foo: z.string(), + bar: z.string().readonly() +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArray = z.object({ + prop: z.optional(z.array(zModelWithString)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing a dictionary + */ +export const zModelWithDictionary = z.object({ + prop: z.optional(z.record(z.string(), z.string())) +}); + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export const zDeprecatedModel = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a model with one property containing a circular reference + */ +export const zModelWithCircularReference = z.object({ + get prop(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zModelWithCircularReference; + })); + } +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * Circle + */ +export const zModelCircle = z.object({ + kind: z.string(), + radius: z.optional(z.number()) +}); + +/** + * Square + */ +export const zModelSquare = z.object({ + kind: z.string(), + sideLength: z.optional(z.number()) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfDiscriminator = z.union([ + z.object({ + kind: z.literal('circle') + }).and(zModelCircle), + z.object({ + kind: z.literal('square') + }).and(zModelSquare) +]); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithAnyOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * This is a model with nested 'any of' property with a type null + */ +export const zCompositionWithNestedAnyAndTypeNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + zModelWithDictionary, + z.null() + ])), + z.array(z.union([ + zModelWithArray, + z.null() + ])) + ])) +}); + +export const z3eNum1Период = z.enum([ + 'Bird', + 'Dog' +]); + +export const zConstValue = z.literal('ConstValue'); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithNestedAnyOfAndNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + z3eNum1Период, + zConstValue + ])), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a model that contains a simple dictionary within composition + */ +export const zCompositionWithOneOfAndSimpleDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.number()) + ])) +}); + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.boolean())) + ])) +}); + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.union([ + z.number(), + z.string() + ]))) + ])) +}); + +/** + * This is a model with one property with a 'all of' relationship + */ +export const zCompositionWithAllOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a base model with two simple optional properties + */ +export const zCompositionBaseModel = z.object({ + firstName: z.optional(z.string()), + lastname: z.optional(z.string()) +}); + +/** + * This is a model that extends the base model + */ +export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ + age: z.number(), + firstName: z.string(), + lastname: z.string() +})); + +/** + * This is a model with one nested property + */ +export const zModelWithNestedProperties = z.object({ + first: z.union([ + z.object({ + second: z.union([ + z.object({ + third: z.union([ + z.string().readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() +}); + +/** + * This is a model with duplicated properties + */ +export const zModelWithDuplicateProperties = z.object({ + prop: z.optional(zModelWithString) +}); + +/** + * This is a model with ordered properties + */ +export const zModelWithOrderedProperties = z.object({ + zebra: z.optional(z.string()), + apple: z.optional(z.string()), + hawaii: z.optional(z.string()) +}); + +/** + * This is a model with duplicated imports + */ +export const zModelWithDuplicateImports = z.object({ + propA: z.optional(zModelWithString), + propB: z.optional(zModelWithString), + propC: z.optional(zModelWithString) +}); + +/** + * This is a model that extends another model + */ +export const zModelThatExtends = zModelWithString.and(z.object({ + propExtendsA: z.optional(z.string()), + propExtendsB: z.optional(zModelWithString) +})); + +/** + * This is a model that extends another model + */ +export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ + propExtendsC: z.optional(z.string()), + propExtendsD: z.optional(zModelWithString) +})); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPattern = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + enabled: z.optional(z.boolean().readonly()), + modified: z.optional(z.iso.datetime().readonly()), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFile = z.object({ + id: z.optional(z.string().min(1).readonly()), + updated_at: z.optional(z.iso.datetime().readonly()), + created_at: z.optional(z.iso.datetime().readonly()), + mime: z.string().min(1).max(24), + file: z.optional(z.url().readonly()) +}); + +export const zDefault = z.object({ + name: z.optional(z.string()) +}); + +export const zPageable = z.object({ + page: z.optional(z.int().gte(0)).default(0), + size: z.optional(z.int().gte(1)), + sort: z.optional(z.array(z.string())) +}); + +/** + * This is a free-form object without additionalProperties. + */ +export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: true. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: {}. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); + +export const zModelWithConst = z.object({ + String: z.optional(z.literal('String')), + number: z.optional(z.literal(0)), + null: z.optional(z.null()), + withType: z.optional(z.literal('Some string')) +}); + +/** + * This is a model with one property and additionalProperties: true + */ +export const zModelWithAdditionalPropertiesEqTrue = z.object({ + prop: z.optional(z.string()) +}); + +export const zNestedAnyOfArraysNullable = z.object({ + nullableArray: z.optional(z.union([ + z.array(z.union([ + z.string(), + z.boolean() + ])), + z.null() + ])) +}); + +/** + * This is a reusable parameter + */ +export const zSimpleParameter = z.unknown(); + +export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ + z.object({ + foo: zSimpleParameter + }), + z.object({ + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 + }) +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * An object that can be null + */ +export const zNullableObject = z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.null() +]).default(null); + +/** + * Some % character + */ +export const zCharactersInDescription = z.string(); + +export const zModelWithNullableObject = z.object({ + data: z.optional(zNullableObject) +}); + +export const zModelWithOneOfEnum = z.union([ + z.object({ + foo: z.enum([ + 'Bar' + ]) + }), + z.object({ + foo: z.enum([ + 'Baz' + ]) + }), + z.object({ + foo: z.enum([ + 'Qux' + ]) + }), + z.object({ + content: z.iso.datetime(), + foo: z.enum([ + 'Quux' + ]) + }), + z.object({ + content: z.tuple([ + z.iso.datetime(), + z.string() + ]), + foo: z.enum([ + 'Corge' + ]) + }) +]); + +export const zModelWithNestedArrayEnumsDataFoo = z.enum([ + 'foo', + 'bar' +]); + +export const zModelWithNestedArrayEnumsDataBar = z.enum([ + 'baz', + 'qux' +]); + +export const zModelWithNestedArrayEnumsData = z.object({ + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) +}); + +export const zModelWithNestedArrayEnums = z.object({ + array_strings: z.optional(z.array(z.string())), + data: z.optional(zModelWithNestedArrayEnumsData) +}); + +export const zModelWithNestedCompositionEnums = z.object({ + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) +}); + +export const zModelWithConstantSizeArray = z.tuple([ + z.number(), + z.number() +]); + +export const zModelWithAnyOfConstantSizeArray = z.tuple([ + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]) +]); + +export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ + zModelWithInteger, + z.union([ + z.number(), + z.string() + ]), + z.string() +]); + +export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]) +]); + +/** + * Model with restricted keyword name + */ +export const zImport = z.string(); + +export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ + z.union([ + z.number(), + zImport + ]), + z.union([ + z.number(), + zImport + ]) +]); + +export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ + z.intersection(z.number(), z.string()), + z.intersection(z.number(), z.string()) +]); + +export const zModelWithNumericEnumUnion = z.object({ + value: z.optional(z.unknown()) +}); + +/** + * Some description with `back ticks` + */ +export const zModelWithBackticksInDescription = z.object({ + template: z.optional(z.string()) +}); + +export const zModelWithOneOfAndProperties = z.intersection(z.union([ + zSimpleParameter, + zNonAsciiStringæøåÆøÅöôêÊ字符串 +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * Model used to test deduplication strategy (unused) + */ +export const zParameterSimpleParameterUnused = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse2 = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData2 = z.string(); + +export const zSchemaWithFormRestrictedKeys = z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()), + object: z.optional(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + })), + array: z.optional(z.array(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + }))) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ + resourceVersion: z.optional(z.string()), + uid: z.optional(z.string()) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) +}); + +export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) +})); + +export const zAdditionalPropertiesIntegerIssue = z.object({ + value: z.int() +}); + +export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemString = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()) +}); + +export const zOneOfAllOfIssue = z.union([ + z.intersection(z.union([ + zConstValue, + zGenericSchemaDuplicateIssue1SystemBoolean + ]), z3eNum1Период), + zGenericSchemaDuplicateIssue1SystemString +]); + +/** + * This is a model with one nested property + */ +export const zModelWithPropertiesWritable = z.object({ + required: z.string(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()) +}); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPatternWritable = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFileWritable = z.object({ + mime: z.string().min(1).max(24) +}); + +export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ + foo: z.string(), + baz: z.string() +}); + +export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zGenericSchemaDuplicateIssue1SystemBooleanWritable = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemStringWritable = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])) +}); + +/** + * Parameter with illegal characters + */ +export const zXFooBar = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleRequestBody = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleFormData = zModelWithString; + +export const zExportData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchApiVbyApiVersionNoTagData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportData = z.object({ + body: z.union([ + zModelWithReadOnlyAndWriteOnlyWritable, + zModelWithArrayReadOnlyAndWriteOnly + ]), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportResponse = z.union([ + zModelFromZendesk, + zModelWithReadOnlyAndWriteOnly +]); + +export const zFooWowData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zApiVVersionODataControllerCountData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; + +export const zGetApiVbyApiVersionSimpleOperationData = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.union([ + z.string(), + z.uuid() + ]) + }), + query: z.optional(z.never()) +}); + +/** + * Response is a simple number + */ +export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); + +export const zDeleteCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zGetCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zHeadCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zOptionsCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPostCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPutCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDeleteFooData3 = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.string(), + BarParam: z.string() + }), + query: z.optional(z.never()), + headers: z.object({ + 'x-Foo-Bar': zModelWithString + }) +}); + +export const zCallWithDescriptionsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterWithBreaks: z.optional(z.string()), + parameterWithBackticks: z.optional(z.string()), + parameterWithSlashes: z.optional(z.string()), + parameterWithExpressionPlaceholders: z.optional(z.string()), + parameterWithQuotes: z.optional(z.string()), + parameterWithReservedCharacters: z.optional(z.string()) + })) +}); + +export const zDeprecatedCallData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()), + headers: z.object({ + parameter: z.union([ + zDeprecatedModel, + z.null() + ]) + }) +}); + +export const zCallWithParametersData = z.object({ + body: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + path: z.object({ + parameterPath: z.union([ + z.string(), + z.null() + ]), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFoo), + foo_all_of_enum: zModelWithNestedArrayEnumsDataFoo, + cursor: z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + parameterHeader: z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zCallWithWeirdParameterNamesData = z.object({ + body: z.union([ + zModelWithString, + z.null() + ]), + path: z.object({ + 'parameter.path.1': z.optional(z.string()), + 'parameter-path-2': z.optional(z.string()), + 'PARAMETER-PATH-3': z.optional(z.string()), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + default: z.optional(z.string()), + 'parameter-query': z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + 'parameter.header': z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zGetCallWithOptionalParamData = z.object({ + body: zModelWithOneOfEnum, + path: z.optional(z.never()), + query: z.optional(z.object({ + page: z.optional(z.number()) + })) +}); + +export const zPostCallWithOptionalParamData = z.object({ + body: z.optional(z.object({ + offset: z.optional(z.union([ + z.number(), + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.object({ + parameter: zPageable + }) +}); + +export const zPostCallWithOptionalParamResponse = z.union([ + z.number(), + z.void() +]); + +export const zPostApiVbyApiVersionRequestBodyData = z.object({ + body: z.optional(zSimpleRequestBody), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zPostApiVbyApiVersionFormDataData = z.object({ + body: z.optional(zSimpleFormData), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zCallWithDefaultParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.union([ + z.string().default('Hello World!'), + z.null() + ])).default('Hello World!'), + parameterNumber: z.optional(z.union([ + z.number().default(123), + z.null() + ])).default(123), + parameterBoolean: z.optional(z.union([ + z.boolean().default(true), + z.null() + ])).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })) +}); + +export const zCallWithDefaultOptionalParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.string()).default('Hello World!'), + parameterNumber: z.optional(z.number()).default(123), + parameterBoolean: z.optional(z.boolean()).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(zModelWithString) + })) +}); + +export const zCallToTestOrderOfParamsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterOptionalStringWithDefault: z.optional(z.string()).default('Hello World!'), + parameterOptionalStringWithEmptyDefault: z.optional(z.string()).default(''), + parameterOptionalStringWithNoDefault: z.optional(z.string()), + parameterStringWithDefault: z.string().default('Hello World!'), + parameterStringWithEmptyDefault: z.string().default(''), + parameterStringWithNoDefault: z.string(), + parameterStringNullableWithNoDefault: z.optional(z.union([ + z.string(), + z.null() + ])), + parameterStringNullableWithDefault: z.optional(z.union([ + z.string(), + z.null() + ])).default(null) + }) +}); + +export const zDuplicateNameData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName2Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName3Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName4Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zCallWithNoContentResponseResponse = z.void(); + +export const zCallWithResponseAndNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseAndNoContentResponseResponse = z.union([ + z.number(), + z.void() +]); + +export const zDummyAData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDummyAResponse = z400; + +export const zDummyBData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zDummyBResponse = z.void(); + +export const zCallWithResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseResponse = zImport; + +export const zCallWithDuplicateResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithDuplicateResponsesResponse = z.union([ + zModelWithBoolean.and(zModelWithInteger), + zModelWithString +]); + +export const zCallWithResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponsesResponse = z.union([ + z.object({ + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()), + value: z.optional(z.array(zModelWithString).readonly()) + }), + zModelThatExtends, + zModelThatExtendsExtends +]); + +export const zCollectionFormatData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterArrayCSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArraySSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayTSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayPipes: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayMulti: z.union([ + z.array(z.string()), + z.null() + ]) + }) +}); + +export const zTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.object({ + id: z.optional(z.int()) + })), + query: z.object({ + parameterNumber: z.number().default(123), + parameterString: z.union([ + z.string().default('default'), + z.null() + ]).default('default'), + parameterBoolean: z.union([ + z.boolean().default(true), + z.null() + ]).default(true), + parameterObject: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]).default(null), + parameterArray: z.union([ + z.array(z.string()), + z.null() + ]), + parameterDictionary: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + parameterEnum: z.union([ + z.literal('Success'), + z.literal('Warning'), + z.literal('Error'), + z.null() + ]) + }) +}); + +export const zTypesResponse = z.union([ + z.number(), + z.string(), + z.boolean(), + z.record(z.string(), z.unknown()) +]); + +export const zUploadFileData = z.object({ + body: z.string(), + path: z.object({ + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.optional(z.never()) +}); + +export const zUploadFileResponse = z.boolean(); + +export const zFileResponseData = z.object({ + body: z.optional(z.never()), + path: z.object({ + id: z.string(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zFileResponseResponse = z.string(); + +export const zComplexTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterObject: z.object({ + first: z.optional(z.object({ + second: z.optional(z.object({ + third: z.optional(z.string()) + })) + })) + }), + parameterReference: zModelWithString + }) +}); + +/** + * Successful response + */ +export const zComplexTypesResponse = z.array(zModelWithString); + +export const zMultipartResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * OK + */ +export const zMultipartResponseResponse = z.object({ + file: z.optional(z.string()), + metadata: z.optional(z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) + })) +}); + +export const zMultipartRequestData = z.object({ + body: z.optional(z.object({ + content: z.optional(z.string()), + data: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zComplexParamsData = z.object({ + body: z.optional(z.object({ + key: z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), + z.null() + ]).readonly(), + name: z.union([ + z.string().max(255), + z.null() + ]), + enabled: z.optional(z.boolean()).default(true), + type: z.enum([ + 'Monkey', + 'Horse', + 'Bird' + ]), + listOfModels: z.optional(z.union([ + z.array(zModelWithString), + z.null() + ])), + listOfStrings: z.optional(z.union([ + z.array(z.string()), + z.null() + ])), + parameters: z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ]), + user: z.optional(z.object({ + id: z.optional(z.int().readonly()), + name: z.optional(z.union([ + z.string().readonly(), + z.null() + ]).readonly()) + }).readonly()) + })), + path: z.object({ + id: z.int(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zComplexParamsResponse = zModelWithString; + +export const zCallWithResultFromHeaderData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zTestErrorCodeData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + status: z.int() + }) +}); + +export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() + }) +}); + +/** + * Successful response + */ +export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); + +export const zPutWithFormUrlEncodedData = z.object({ + body: zArrayWithStrings, + path: z.optional(z.never()), + query: z.optional(z.never()) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/client.gen.ts new file mode 100644 index 000000000..b6d0dff2d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/client.gen.ts @@ -0,0 +1,272 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + 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-fetch/sdk-preserve-wire-casing/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/types.gen.ts new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/utils.gen.ts new file mode 100644 index 000000000..b4bcc4d19 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/client/utils.gen.ts @@ -0,0 +1,331 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdk.gen.ts new file mode 100644 index 000000000..b5f8b7d55 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-preserve-wire-casing/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index 67961302b..31085f171 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60f..c703e9ed4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/client.gen.ts new file mode 100644 index 000000000..2e86bede8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/client.gen.ts @@ -0,0 +1,266 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + const requestInit: ReqInit = { + ...opts, + body: getValidRequestBody(opts), + }; + + let response = await _fetch(url, requestInit); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, opts); + } + } + + const result = { + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + return { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + const requestInit = { + ...init, + method: init.method as Config['method'], + url, + }; + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(requestInit); + request = new Request(requestInit.url, requestInit); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/types.gen.ts new file mode 100644 index 000000000..76f0bf322 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/types.gen.ts @@ -0,0 +1,217 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise<{ + data: TData extends Record ? TData[keyof TData] : TData; + response: Response; + }> + : Promise< + ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/utils.gen.ts new file mode 100644 index 000000000..d87d7af62 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/client/utils.gen.ts @@ -0,0 +1,437 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + options: Options, +) => Err | Promise; + +type ReqInterceptor = (options: Options) => void | Promise; + +type ResInterceptor = ( + response: Res, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdk.gen.ts new file mode 100644 index 000000000..b5f8b7d55 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-extreme/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/client.gen.ts new file mode 100644 index 000000000..2e86bede8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/client.gen.ts @@ -0,0 +1,266 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + const requestInit: ReqInit = { + ...opts, + body: getValidRequestBody(opts), + }; + + let response = await _fetch(url, requestInit); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, opts); + } + } + + const result = { + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + return { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + const requestInit = { + ...init, + method: init.method as Config['method'], + url, + }; + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(requestInit); + request = new Request(requestInit.url, requestInit); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/types.gen.ts new file mode 100644 index 000000000..76f0bf322 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/types.gen.ts @@ -0,0 +1,217 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise<{ + data: TData extends Record ? TData[keyof TData] : TData; + response: Response; + }> + : Promise< + ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/utils.gen.ts new file mode 100644 index 000000000..d87d7af62 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/client/utils.gen.ts @@ -0,0 +1,437 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + options: Options, +) => Err | Promise; + +type ReqInterceptor = (options: Options) => void | Promise; + +type ResInterceptor = ( + response: Res, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdk.gen.ts new file mode 100644 index 000000000..bf18a40f8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdk.gen.ts @@ -0,0 +1,657 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { zExportData, zPatchApiVbyApiVersionNoTagData, zImportData, zImportResponse, zFooWowData, zApiVVersionODataControllerCountData, zApiVVersionODataControllerCountResponse, zGetApiVbyApiVersionSimpleOperationData, zGetApiVbyApiVersionSimpleOperationResponse, zDeleteCallWithoutParametersAndResponseData, zGetCallWithoutParametersAndResponseData, zHeadCallWithoutParametersAndResponseData, zOptionsCallWithoutParametersAndResponseData, zPatchCallWithoutParametersAndResponseData, zPostCallWithoutParametersAndResponseData, zPutCallWithoutParametersAndResponseData, zDeleteFooData3 as zDeleteFooData, zCallWithDescriptionsData, zDeprecatedCallData, zCallWithParametersData, zCallWithWeirdParameterNamesData, zGetCallWithOptionalParamData, zPostCallWithOptionalParamData, zPostCallWithOptionalParamResponse, zPostApiVbyApiVersionRequestBodyData, zPostApiVbyApiVersionFormDataData, zCallWithDefaultParametersData, zCallWithDefaultOptionalParametersData, zCallToTestOrderOfParamsData, zDuplicateNameData, zDuplicateName2Data, zDuplicateName3Data, zDuplicateName4Data, zCallWithNoContentResponseData, zCallWithNoContentResponseResponse, zCallWithResponseAndNoContentResponseData, zCallWithResponseAndNoContentResponseResponse, zDummyAData, zDummyAResponse, zDummyBData, zDummyBResponse, zCallWithResponseData, zCallWithResponseResponse, zCallWithDuplicateResponsesData, zCallWithDuplicateResponsesResponse, zCallWithResponsesData, zCallWithResponsesResponse, zCollectionFormatData, zTypesData, zTypesResponse, zUploadFileData, zUploadFileResponse, zFileResponseData, zFileResponseResponse, zComplexTypesData, zComplexTypesResponse, zMultipartResponseData, zMultipartResponseResponse, zMultipartRequestData, zComplexParamsData, zComplexParamsResponse, zCallWithResultFromHeaderData, zTestErrorCodeData, zNonAsciiæøåÆøÅöôêÊ字符串Data, zNonAsciiæøåÆøÅöôêÊ字符串Response, zPutWithFormUrlEncodedData } from './zod.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + requestValidator: async (data) => { + return await zExportData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchApiVbyApiVersionNoTagData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + requestValidator: async (data) => { + return await zImportData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zImportResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + requestValidator: async (data) => { + return await zFooWowData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + requestValidator: async (data) => { + return await zApiVVersionODataControllerCountData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zApiVVersionODataControllerCountResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + requestValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zHeadCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zOptionsCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPutCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteFooData.parseAsync(data); + }, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDescriptionsData.parseAsync(data); + }, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + requestValidator: async (data) => { + return await zDeprecatedCallData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithWeirdParameterNamesData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithOptionalParamData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithOptionalParamData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zPostCallWithOptionalParamResponse.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionRequestBodyData.parseAsync(data); + }, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionFormDataData.parseAsync(data); + }, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultOptionalParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallToTestOrderOfParamsData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateNameData.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName2Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName3Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName4Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + requestValidator: async (data) => { + return await zDummyAData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyAResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + requestValidator: async (data) => { + return await zDummyBData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyBResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDuplicateResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithDuplicateResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + requestValidator: async (data) => { + return await zCollectionFormatData.parseAsync(data); + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + requestValidator: async (data) => { + return await zTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + requestValidator: async (data) => { + return await zUploadFileData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zUploadFileResponse.parseAsync(data); + }, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zFileResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zFileResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zMultipartResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartRequestData.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexParamsData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexParamsResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResultFromHeaderData.parseAsync(data); + }, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + requestValidator: async (data) => { + return await zTestErrorCodeData.parseAsync(data); + }, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + requestValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Data.parseAsync(data); + }, + responseValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Response.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + requestValidator: async (data) => { + return await zPutWithFormUrlEncodedData.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/zod.gen.ts new file mode 100644 index 000000000..a08796446 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing-zod/zod.gen.ts @@ -0,0 +1,1790 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +/** + * Model with number-only name + */ +export const z400 = z.string(); + +export const zExternalSharedExternalSharedModel = z.object({ + id: z.string(), + name: z.optional(z.string()) +}); + +/** + * External ref to shared model (A) + */ +export const zExternalRefA = zExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export const zExternalRefB = zExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCamelCaseCommentWithBreaks = z.int(); + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCommentWithBreaks = z.int(); + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export const zCommentWithBackticks = z.int(); + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export const zCommentWithBackticksAndQuotes = z.int(); + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export const zCommentWithSlashes = z.int(); + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export const zCommentWithExpressionPlaceholders = z.int(); + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export const zCommentWithQuotes = z.int(); + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export const zCommentWithReservedCharacters = z.int(); + +/** + * This is a simple number + */ +export const zSimpleInteger = z.int(); + +/** + * This is a simple boolean + */ +export const zSimpleBoolean = z.boolean(); + +/** + * This is a simple string + */ +export const zSimpleString = z.string(); + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); + +/** + * This is a simple file + */ +export const zSimpleFile = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithString = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a simple reference + */ +export const zSimpleReference = zModelWithString; + +/** + * This is a simple string + */ +export const zSimpleStringWithPattern = z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + z.null() +]); + +/** + * This is a simple enum with strings + */ +export const zEnumWithStrings = z.enum([ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串' +]); + +export const zEnumWithReplacedCharacters = z.enum([ + "'Single Quote'", + '"Double Quotes"', + 'øæåôöØÆÅÔÖ字符串', + '' +]); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithNumbers = z.unknown(); + +/** + * Success=1,Warning=2,Error=3 + */ +export const zEnumFromDescription = z.number(); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithExtensions = z.unknown(); + +export const zEnumWithXEnumNames = z.unknown(); + +/** + * This is a simple array with numbers + */ +export const zArrayWithNumbers = z.array(z.int()); + +/** + * This is a simple array with booleans + */ +export const zArrayWithBooleans = z.array(z.boolean()); + +/** + * This is a simple array with strings + */ +export const zArrayWithStrings = z.array(z.string()).default(['test']); + +/** + * This is a simple array with references + */ +export const zArrayWithReferences = z.array(zModelWithString); + +/** + * This is a simple array containing an array + */ +export const zArrayWithArray = z.array(z.array(zModelWithString)); + +/** + * This is a simple array with properties + */ +export const zArrayWithProperties = z.array(z.object({ + '16x16': z.optional(zCamelCaseCommentWithBreaks), + bar: z.optional(z.string()) +})); + +/** + * This is a simple array with any of properties + */ +export const zArrayWithAnyOfProperties = z.array(z.union([ + z.object({ + foo: z.optional(z.string()).default('test') + }), + z.object({ + bar: z.optional(z.string()) + }) +])); + +export const zAnyOfAnyAndNull = z.object({ + data: z.optional(z.union([ + z.unknown(), + z.null() + ])) +}); + +/** + * This is a simple array with any of properties + */ +export const zAnyOfArrays = z.object({ + results: z.optional(z.array(z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.object({ + bar: z.optional(z.string()) + }) + ]))) +}); + +/** + * This is a string dictionary + */ +export const zDictionaryWithString = z.record(z.string(), z.string()); + +export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ + foo: z.optional(z.number()), + bar: z.optional(z.boolean()) +}); + +/** + * This is a string reference + */ +export const zDictionaryWithReference = z.record(z.string(), zModelWithString); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); + +/** + * This is a string dictionary + */ +export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithProperties = z.record(z.string(), z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) +})); + +/** + * This is a model with one number property + */ +export const zModelWithInteger = z.object({ + prop: z.optional(z.int()) +}); + +/** + * This is a model with one boolean property + */ +export const zModelWithBoolean = z.object({ + prop: z.optional(z.boolean()) +}); + +/** + * This is a model with one string property + */ +export const zModelWithStringError = z.object({ + prop: z.optional(z.string()) +}); + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export const zModelFromZendesk = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithNullableString = z.object({ + nullableProp1: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp1: z.union([ + z.string(), + z.null() + ]), + nullableProp2: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp2: z.union([ + z.string(), + z.null() + ]), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnum = z.object({ + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])), + statusCode: z.optional(z.enum([ + '100', + '200 FOO', + '300 FOO_BAR', + '400 foo-bar', + '500 foo.bar', + '600 foo&bar' + ])), + bool: z.optional(z.unknown()) +}); + +/** + * This is a model with one enum with escaped name + */ +export const zModelWithEnumWithHyphen = z.object({ + 'foo-bar-baz-qux': z.optional(z.enum([ + '3.0' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnumFromDescription = z.object({ + test: z.optional(z.int()) +}); + +/** + * This is a model with nested enums + */ +export const zModelWithNestedEnums = z.object({ + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), + arrayWithEnum: z.optional(z.array(z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + arrayWithDescription: z.optional(z.array(z.int())), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one nested property + */ +export const zModelWithProperties = z.object({ + required: z.string(), + requiredAndReadOnly: z.string().readonly(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()), + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()) +}); + +/** + * This is a model with one property containing a reference + */ +export const zModelWithReference = z.object({ + prop: z.optional(zModelWithProperties) +}); + +export const zModelWithReadOnlyAndWriteOnly = z.object({ + foo: z.string(), + bar: z.string().readonly() +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArray = z.object({ + prop: z.optional(z.array(zModelWithString)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing a dictionary + */ +export const zModelWithDictionary = z.object({ + prop: z.optional(z.record(z.string(), z.string())) +}); + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export const zDeprecatedModel = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a model with one property containing a circular reference + */ +export const zModelWithCircularReference = z.object({ + get prop(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zModelWithCircularReference; + })); + } +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * Circle + */ +export const zModelCircle = z.object({ + kind: z.string(), + radius: z.optional(z.number()) +}); + +/** + * Square + */ +export const zModelSquare = z.object({ + kind: z.string(), + sideLength: z.optional(z.number()) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfDiscriminator = z.union([ + z.object({ + kind: z.literal('circle') + }).and(zModelCircle), + z.object({ + kind: z.literal('square') + }).and(zModelSquare) +]); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithAnyOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * This is a model with nested 'any of' property with a type null + */ +export const zCompositionWithNestedAnyAndTypeNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + zModelWithDictionary, + z.null() + ])), + z.array(z.union([ + zModelWithArray, + z.null() + ])) + ])) +}); + +export const z3eNum1Период = z.enum([ + 'Bird', + 'Dog' +]); + +export const zConstValue = z.literal('ConstValue'); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithNestedAnyOfAndNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + z3eNum1Период, + zConstValue + ])), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a model that contains a simple dictionary within composition + */ +export const zCompositionWithOneOfAndSimpleDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.number()) + ])) +}); + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.boolean())) + ])) +}); + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.union([ + z.number(), + z.string() + ]))) + ])) +}); + +/** + * This is a model with one property with a 'all of' relationship + */ +export const zCompositionWithAllOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a base model with two simple optional properties + */ +export const zCompositionBaseModel = z.object({ + firstName: z.optional(z.string()), + lastname: z.optional(z.string()) +}); + +/** + * This is a model that extends the base model + */ +export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ + age: z.number(), + firstName: z.string(), + lastname: z.string() +})); + +/** + * This is a model with one nested property + */ +export const zModelWithNestedProperties = z.object({ + first: z.union([ + z.object({ + second: z.union([ + z.object({ + third: z.union([ + z.string().readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() +}); + +/** + * This is a model with duplicated properties + */ +export const zModelWithDuplicateProperties = z.object({ + prop: z.optional(zModelWithString) +}); + +/** + * This is a model with ordered properties + */ +export const zModelWithOrderedProperties = z.object({ + zebra: z.optional(z.string()), + apple: z.optional(z.string()), + hawaii: z.optional(z.string()) +}); + +/** + * This is a model with duplicated imports + */ +export const zModelWithDuplicateImports = z.object({ + propA: z.optional(zModelWithString), + propB: z.optional(zModelWithString), + propC: z.optional(zModelWithString) +}); + +/** + * This is a model that extends another model + */ +export const zModelThatExtends = zModelWithString.and(z.object({ + propExtendsA: z.optional(z.string()), + propExtendsB: z.optional(zModelWithString) +})); + +/** + * This is a model that extends another model + */ +export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ + propExtendsC: z.optional(z.string()), + propExtendsD: z.optional(zModelWithString) +})); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPattern = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + enabled: z.optional(z.boolean().readonly()), + modified: z.optional(z.iso.datetime().readonly()), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFile = z.object({ + id: z.optional(z.string().min(1).readonly()), + updated_at: z.optional(z.iso.datetime().readonly()), + created_at: z.optional(z.iso.datetime().readonly()), + mime: z.string().min(1).max(24), + file: z.optional(z.url().readonly()) +}); + +export const zDefault = z.object({ + name: z.optional(z.string()) +}); + +export const zPageable = z.object({ + page: z.optional(z.int().gte(0)).default(0), + size: z.optional(z.int().gte(1)), + sort: z.optional(z.array(z.string())) +}); + +/** + * This is a free-form object without additionalProperties. + */ +export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: true. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: {}. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); + +export const zModelWithConst = z.object({ + String: z.optional(z.literal('String')), + number: z.optional(z.literal(0)), + null: z.optional(z.null()), + withType: z.optional(z.literal('Some string')) +}); + +/** + * This is a model with one property and additionalProperties: true + */ +export const zModelWithAdditionalPropertiesEqTrue = z.object({ + prop: z.optional(z.string()) +}); + +export const zNestedAnyOfArraysNullable = z.object({ + nullableArray: z.optional(z.union([ + z.array(z.union([ + z.string(), + z.boolean() + ])), + z.null() + ])) +}); + +/** + * This is a reusable parameter + */ +export const zSimpleParameter = z.unknown(); + +export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ + z.object({ + foo: zSimpleParameter + }), + z.object({ + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 + }) +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * An object that can be null + */ +export const zNullableObject = z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.null() +]).default(null); + +/** + * Some % character + */ +export const zCharactersInDescription = z.string(); + +export const zModelWithNullableObject = z.object({ + data: z.optional(zNullableObject) +}); + +export const zModelWithOneOfEnum = z.union([ + z.object({ + foo: z.enum([ + 'Bar' + ]) + }), + z.object({ + foo: z.enum([ + 'Baz' + ]) + }), + z.object({ + foo: z.enum([ + 'Qux' + ]) + }), + z.object({ + content: z.iso.datetime(), + foo: z.enum([ + 'Quux' + ]) + }), + z.object({ + content: z.tuple([ + z.iso.datetime(), + z.string() + ]), + foo: z.enum([ + 'Corge' + ]) + }) +]); + +export const zModelWithNestedArrayEnumsDataFoo = z.enum([ + 'foo', + 'bar' +]); + +export const zModelWithNestedArrayEnumsDataBar = z.enum([ + 'baz', + 'qux' +]); + +export const zModelWithNestedArrayEnumsData = z.object({ + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) +}); + +export const zModelWithNestedArrayEnums = z.object({ + array_strings: z.optional(z.array(z.string())), + data: z.optional(zModelWithNestedArrayEnumsData) +}); + +export const zModelWithNestedCompositionEnums = z.object({ + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) +}); + +export const zModelWithConstantSizeArray = z.tuple([ + z.number(), + z.number() +]); + +export const zModelWithAnyOfConstantSizeArray = z.tuple([ + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]) +]); + +export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ + zModelWithInteger, + z.union([ + z.number(), + z.string() + ]), + z.string() +]); + +export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]) +]); + +/** + * Model with restricted keyword name + */ +export const zImport = z.string(); + +export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ + z.union([ + z.number(), + zImport + ]), + z.union([ + z.number(), + zImport + ]) +]); + +export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ + z.intersection(z.number(), z.string()), + z.intersection(z.number(), z.string()) +]); + +export const zModelWithNumericEnumUnion = z.object({ + value: z.optional(z.unknown()) +}); + +/** + * Some description with `back ticks` + */ +export const zModelWithBackticksInDescription = z.object({ + template: z.optional(z.string()) +}); + +export const zModelWithOneOfAndProperties = z.intersection(z.union([ + zSimpleParameter, + zNonAsciiStringæøåÆøÅöôêÊ字符串 +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * Model used to test deduplication strategy (unused) + */ +export const zParameterSimpleParameterUnused = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse2 = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData2 = z.string(); + +export const zSchemaWithFormRestrictedKeys = z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()), + object: z.optional(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + })), + array: z.optional(z.array(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + }))) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ + resourceVersion: z.optional(z.string()), + uid: z.optional(z.string()) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) +}); + +export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) +})); + +export const zAdditionalPropertiesIntegerIssue = z.object({ + value: z.int() +}); + +export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemString = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()) +}); + +export const zOneOfAllOfIssue = z.union([ + z.intersection(z.union([ + zConstValue, + zGenericSchemaDuplicateIssue1SystemBoolean + ]), z3eNum1Период), + zGenericSchemaDuplicateIssue1SystemString +]); + +/** + * This is a model with one nested property + */ +export const zModelWithPropertiesWritable = z.object({ + required: z.string(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()) +}); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPatternWritable = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFileWritable = z.object({ + mime: z.string().min(1).max(24) +}); + +export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ + foo: z.string(), + baz: z.string() +}); + +export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zGenericSchemaDuplicateIssue1SystemBooleanWritable = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemStringWritable = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])) +}); + +/** + * Parameter with illegal characters + */ +export const zXFooBar = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleRequestBody = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleFormData = zModelWithString; + +export const zExportData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchApiVbyApiVersionNoTagData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportData = z.object({ + body: z.union([ + zModelWithReadOnlyAndWriteOnlyWritable, + zModelWithArrayReadOnlyAndWriteOnly + ]), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportResponse = z.union([ + zModelFromZendesk, + zModelWithReadOnlyAndWriteOnly +]); + +export const zFooWowData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zApiVVersionODataControllerCountData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; + +export const zGetApiVbyApiVersionSimpleOperationData = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.union([ + z.string(), + z.uuid() + ]) + }), + query: z.optional(z.never()) +}); + +/** + * Response is a simple number + */ +export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); + +export const zDeleteCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zGetCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zHeadCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zOptionsCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPostCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPutCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDeleteFooData3 = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.string(), + BarParam: z.string() + }), + query: z.optional(z.never()), + headers: z.object({ + 'x-Foo-Bar': zModelWithString + }) +}); + +export const zCallWithDescriptionsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterWithBreaks: z.optional(z.string()), + parameterWithBackticks: z.optional(z.string()), + parameterWithSlashes: z.optional(z.string()), + parameterWithExpressionPlaceholders: z.optional(z.string()), + parameterWithQuotes: z.optional(z.string()), + parameterWithReservedCharacters: z.optional(z.string()) + })) +}); + +export const zDeprecatedCallData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()), + headers: z.object({ + parameter: z.union([ + zDeprecatedModel, + z.null() + ]) + }) +}); + +export const zCallWithParametersData = z.object({ + body: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + path: z.object({ + parameterPath: z.union([ + z.string(), + z.null() + ]), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFoo), + foo_all_of_enum: zModelWithNestedArrayEnumsDataFoo, + cursor: z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + parameterHeader: z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zCallWithWeirdParameterNamesData = z.object({ + body: z.union([ + zModelWithString, + z.null() + ]), + path: z.object({ + 'parameter.path.1': z.optional(z.string()), + 'parameter-path-2': z.optional(z.string()), + 'PARAMETER-PATH-3': z.optional(z.string()), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + default: z.optional(z.string()), + 'parameter-query': z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + 'parameter.header': z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zGetCallWithOptionalParamData = z.object({ + body: zModelWithOneOfEnum, + path: z.optional(z.never()), + query: z.optional(z.object({ + page: z.optional(z.number()) + })) +}); + +export const zPostCallWithOptionalParamData = z.object({ + body: z.optional(z.object({ + offset: z.optional(z.union([ + z.number(), + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.object({ + parameter: zPageable + }) +}); + +export const zPostCallWithOptionalParamResponse = z.union([ + z.number(), + z.void() +]); + +export const zPostApiVbyApiVersionRequestBodyData = z.object({ + body: z.optional(zSimpleRequestBody), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zPostApiVbyApiVersionFormDataData = z.object({ + body: z.optional(zSimpleFormData), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zCallWithDefaultParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.union([ + z.string().default('Hello World!'), + z.null() + ])).default('Hello World!'), + parameterNumber: z.optional(z.union([ + z.number().default(123), + z.null() + ])).default(123), + parameterBoolean: z.optional(z.union([ + z.boolean().default(true), + z.null() + ])).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })) +}); + +export const zCallWithDefaultOptionalParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.string()).default('Hello World!'), + parameterNumber: z.optional(z.number()).default(123), + parameterBoolean: z.optional(z.boolean()).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(zModelWithString) + })) +}); + +export const zCallToTestOrderOfParamsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterOptionalStringWithDefault: z.optional(z.string()).default('Hello World!'), + parameterOptionalStringWithEmptyDefault: z.optional(z.string()).default(''), + parameterOptionalStringWithNoDefault: z.optional(z.string()), + parameterStringWithDefault: z.string().default('Hello World!'), + parameterStringWithEmptyDefault: z.string().default(''), + parameterStringWithNoDefault: z.string(), + parameterStringNullableWithNoDefault: z.optional(z.union([ + z.string(), + z.null() + ])), + parameterStringNullableWithDefault: z.optional(z.union([ + z.string(), + z.null() + ])).default(null) + }) +}); + +export const zDuplicateNameData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName2Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName3Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName4Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zCallWithNoContentResponseResponse = z.void(); + +export const zCallWithResponseAndNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseAndNoContentResponseResponse = z.union([ + z.number(), + z.void() +]); + +export const zDummyAData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDummyAResponse = z400; + +export const zDummyBData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zDummyBResponse = z.void(); + +export const zCallWithResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseResponse = zImport; + +export const zCallWithDuplicateResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithDuplicateResponsesResponse = z.union([ + zModelWithBoolean.and(zModelWithInteger), + zModelWithString +]); + +export const zCallWithResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponsesResponse = z.union([ + z.object({ + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()), + value: z.optional(z.array(zModelWithString).readonly()) + }), + zModelThatExtends, + zModelThatExtendsExtends +]); + +export const zCollectionFormatData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterArrayCSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArraySSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayTSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayPipes: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayMulti: z.union([ + z.array(z.string()), + z.null() + ]) + }) +}); + +export const zTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.object({ + id: z.optional(z.int()) + })), + query: z.object({ + parameterNumber: z.number().default(123), + parameterString: z.union([ + z.string().default('default'), + z.null() + ]).default('default'), + parameterBoolean: z.union([ + z.boolean().default(true), + z.null() + ]).default(true), + parameterObject: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]).default(null), + parameterArray: z.union([ + z.array(z.string()), + z.null() + ]), + parameterDictionary: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + parameterEnum: z.union([ + z.literal('Success'), + z.literal('Warning'), + z.literal('Error'), + z.null() + ]) + }) +}); + +export const zTypesResponse = z.union([ + z.number(), + z.string(), + z.boolean(), + z.record(z.string(), z.unknown()) +]); + +export const zUploadFileData = z.object({ + body: z.string(), + path: z.object({ + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.optional(z.never()) +}); + +export const zUploadFileResponse = z.boolean(); + +export const zFileResponseData = z.object({ + body: z.optional(z.never()), + path: z.object({ + id: z.string(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zFileResponseResponse = z.string(); + +export const zComplexTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterObject: z.object({ + first: z.optional(z.object({ + second: z.optional(z.object({ + third: z.optional(z.string()) + })) + })) + }), + parameterReference: zModelWithString + }) +}); + +/** + * Successful response + */ +export const zComplexTypesResponse = z.array(zModelWithString); + +export const zMultipartResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * OK + */ +export const zMultipartResponseResponse = z.object({ + file: z.optional(z.string()), + metadata: z.optional(z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) + })) +}); + +export const zMultipartRequestData = z.object({ + body: z.optional(z.object({ + content: z.optional(z.string()), + data: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zComplexParamsData = z.object({ + body: z.optional(z.object({ + key: z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), + z.null() + ]).readonly(), + name: z.union([ + z.string().max(255), + z.null() + ]), + enabled: z.optional(z.boolean()).default(true), + type: z.enum([ + 'Monkey', + 'Horse', + 'Bird' + ]), + listOfModels: z.optional(z.union([ + z.array(zModelWithString), + z.null() + ])), + listOfStrings: z.optional(z.union([ + z.array(z.string()), + z.null() + ])), + parameters: z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ]), + user: z.optional(z.object({ + id: z.optional(z.int().readonly()), + name: z.optional(z.union([ + z.string().readonly(), + z.null() + ]).readonly()) + }).readonly()) + })), + path: z.object({ + id: z.int(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zComplexParamsResponse = zModelWithString; + +export const zCallWithResultFromHeaderData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zTestErrorCodeData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + status: z.int() + }) +}); + +export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() + }) +}); + +/** + * Successful response + */ +export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); + +export const zPutWithFormUrlEncodedData = z.object({ + body: zArrayWithStrings, + path: z.optional(z.never()), + query: z.optional(z.never()) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client.gen.ts new file mode 100644 index 000000000..950198e01 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/client.gen.ts new file mode 100644 index 000000000..2e86bede8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/client.gen.ts @@ -0,0 +1,266 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + // @ts-expect-error + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + const requestInit: ReqInit = { + ...opts, + body: getValidRequestBody(opts), + }; + + let response = await _fetch(url, requestInit); + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, opts); + } + } + + const result = { + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + return { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + const requestInit = { + ...init, + method: init.method as Config['method'], + url, + }; + for (const fn of interceptors.request.fns) { + if (fn) { + await fn(requestInit); + request = new Request(requestInit.url, requestInit); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/index.ts new file mode 100644 index 000000000..8ddc04f42 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/index.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/types.gen.ts new file mode 100644 index 000000000..76f0bf322 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/types.gen.ts @@ -0,0 +1,217 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * 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' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, +> = ThrowOnError extends true + ? Promise<{ + data: TData extends Record ? TData[keyof TData] : TData; + response: Response; + }> + : Promise< + ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys, 'body' | 'url'> & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys, 'headers' | 'url'> & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/utils.gen.ts new file mode 100644 index 000000000..d87d7af62 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/client/utils.gen.ts @@ -0,0 +1,437 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + options: Options, +) => Err | Promise; + +type ReqInterceptor = (options: Options) => void | Promise; + +type ResInterceptor = ( + response: Res, + options: Options, +) => Res | Promise; + +class Interceptors { + fns: Array = []; + + clear(): void { + this.fns = []; + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; + } + return false; + } + + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; + } +} + +export interface Middleware { + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; +} + +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdk.gen.ts new file mode 100644 index 000000000..b5f8b7d55 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/types.gen.ts new file mode 100644 index 000000000..2c8c6af53 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-preserve-wire-casing/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 12468638a..eabb49004 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60f..c703e9ed4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/client.gen.ts new file mode 100644 index 000000000..f9fd67a26 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/client.gen.ts @@ -0,0 +1,233 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { + useAsyncData, + useFetch, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import { reactive, ref, watch } from 'vue'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + executeFetchFn, + mergeConfigs, + mergeHeaders, + mergeInterceptors, + serializeBody, + setAuthParams, + unwrapRefs, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = ({ + asyncDataOptions, + composable = '$fetch', + ...options + }) => { + const key = options.key; + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + const { + requestValidator, + responseTransformer, + responseValidator, + security, + } = opts; + if (requestValidator || security) { + // auth must happen in interceptors otherwise we'd need to require + // asyncContext enabled + // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext + opts.onRequest = [ + async ({ options }) => { + if (security) { + await setAuthParams({ + auth: opts.auth, + headers: options.headers, + query: options.query, + security, + }); + } + + if (requestValidator) { + await requestValidator({ + ...options, + // @ts-expect-error + body: options.rawBody, + }); + } + }, + ...opts.onRequest, + ]; + } + + if (responseTransformer || responseValidator) { + opts.onResponse = [ + ...opts.onResponse, + async ({ options, response }) => { + if (options.responseType && options.responseType !== 'json') { + return; + } + + if (!response.ok) { + return; + } + + if (responseValidator) { + await responseValidator(response._data); + } + + if (responseTransformer) { + response._data = await responseTransformer(response._data); + } + }, + ]; + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.body === '') { + opts.headers.delete('Content-Type'); + } + + const fetchFn = opts.$fetch; + + if (composable === '$fetch') { + return executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + } + + if (composable === 'useFetch' || composable === 'useLazyFetch') { + opts.rawBody = opts.body; + const bodyParams = reactive({ + body: opts.body, + bodySerializer: opts.bodySerializer, + }); + const body = ref(serializeBody(opts)); + opts.body = body; + watch(bodyParams, (changed) => { + body.value = serializeBody(changed); + }); + return composable === 'useLazyFetch' + ? useLazyFetch(() => buildUrl(opts), opts) + : useFetch(() => buildUrl(opts), opts); + } + + const handler: any = () => + executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + + if (composable === 'useAsyncData') { + return key + ? useAsyncData(key, handler, asyncDataOptions) + : useAsyncData(handler, asyncDataOptions); + } + + if (composable === 'useLazyAsyncData') { + return key + ? useLazyAsyncData(key, handler, asyncDataOptions) + : useLazyAsyncData(handler, asyncDataOptions); + } + + return undefined as any; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...unwrapRefs(opts), + body: opts.body as BodyInit | null | undefined, + method, + onRequest: undefined, + signal: unwrapRefs(opts.signal) as AbortSignal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/index.ts new file mode 100644 index 000000000..a2e8f2493 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/index.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Composable, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/types.gen.ts new file mode 100644 index 000000000..ac663764d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AsyncDataOptions, + useAsyncData, + useFetch, + UseFetchOptions, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import type { Ref } from 'vue'; + +import type { Auth } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; +type ObjectStyle = 'form' | 'deepObject'; + +export type QuerySerializer = ( + query: Parameters[0]['query'], +) => string; + +type WithRefs = { + [K in keyof TData]: NonNullable extends object + ? WithRefs> | Ref> + : NonNullable | Ref>; +}; + +// copied from Nuxt +export type KeysOf = Array< + T extends T ? (keyof T extends string ? keyof T : never) : never +>; + +export interface Config + extends Omit< + FetchOptions, + 'baseURL' | 'body' | 'headers' | 'method' | 'query' + >, + WithRefs, 'query'>>, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; +} + +export interface RequestOptions< + TComposable extends Composable = '$fetch', + ResT = unknown, + DefaultT = undefined, + Url extends string = string, +> extends Config, + WithRefs<{ + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + rawBody?: unknown; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + asyncDataOptions?: AsyncDataOptions, DefaultT>; + composable?: TComposable; + key?: string; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export type RequestResult< + TComposable extends Composable, + ResT, + TError, +> = TComposable extends '$fetch' + ? ReturnType> + : TComposable extends 'useAsyncData' + ? ReturnType> + : TComposable extends 'useFetch' + ? ReturnType> + : TComposable extends 'useLazyAsyncData' + ? ReturnType> + : TComposable extends 'useLazyFetch' + ? ReturnType> + : never; + +export interface ClientOptions { + baseURL?: string; +} + +type MethodFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => Promise>>; + +type RequestFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + url: string; +} + +export type BuildUrlOptions< + TData extends Omit = Omit, +> = Pick, 'path' | 'query'> & + Pick & + Pick, 'baseURL' | 'querySerializer'>; + +type BuildUrlFn = >( + options: BuildUrlOptions, +) => string; + +export type Client = CoreClient; + +type OmitKeys = Pick>; + +export type Options< + TComposable extends Composable = '$fetch', + TData extends TDataShape = TDataShape, + ResT = unknown, + DefaultT = undefined, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + WithRefs>; + +export type OptionsLegacyParser = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys & TData + : OmitKeys & + TData & + Pick + : TData extends { headers?: any } + ? OmitKeys & + TData & + Pick + : OmitKeys & TData; + +type FetchOptions = Omit< + UseFetchOptions, + keyof AsyncDataOptions +>; + +export type Composable = + | '$fetch' + | 'useAsyncData' + | 'useFetch' + | 'useLazyAsyncData' + | 'useLazyFetch'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/utils.gen.ts new file mode 100644 index 000000000..0a1d343e2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/client/utils.gen.ts @@ -0,0 +1,389 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ComputedRef, Ref } from 'vue'; +import { isRef, toValue, unref } from 'vue'; + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { + ArraySeparatorStyle, + BuildUrlOptions, + Client, + ClientOptions, + Config, + QuerySerializer, + RequestOptions, +} from './types.gen'; + +type PathSerializer = Pick, 'path' | 'url'>; + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type MaybeArray = T | T[]; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = toValue(toValue(path)[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + const qParams = toValue(queryParams); + if (qParams && typeof qParams === 'object') { + for (const name in qParams) { + const value = toValue(qParams[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + toValue(options.query)?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + toValue(options.query)[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: Pick & { + baseUrl?: string; + querySerializer: QuerySerializer; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseURL?.endsWith('/')) { + config.baseURL = config.baseURL.substring(0, config.baseURL.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + let h: unknown = header; + if (isRef(h)) { + h = unref(h); + } + + const iterator = + h instanceof Headers + ? headersEntries(h) + : Object.entries(h as Record); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, unwrapRefs(v) as string); + } + } else if (value !== undefined) { + const v = unwrapRefs(value); + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof v === 'object' ? JSON.stringify(v) : (v as string), + ); + } + } + } + return mergedHeaders; +}; + +export const mergeInterceptors = (...args: Array>): Array => + args.reduce>((acc, item) => { + if (typeof item === 'function') { + acc.push(item); + } else if (Array.isArray(item)) { + return acc.concat(item); + } + return acc; + }, []); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); + +type UnwrapRefs = + T extends Ref + ? V + : T extends ComputedRef + ? V + : T extends Record // this doesn't handle functions well + ? { [K in keyof T]: UnwrapRefs } + : T; + +export const unwrapRefs = (value: T): UnwrapRefs => { + if (value === null || typeof value !== 'object' || value instanceof Headers) { + return (isRef(value) ? unref(value) : value) as UnwrapRefs; + } + + if (Array.isArray(value)) { + return value.map((item) => unwrapRefs(item)) as UnwrapRefs; + } + + if (isRef(value)) { + return unwrapRefs(unref(value) as T); + } + + // unwrap into new object to avoid modifying the source + const result: Record = {}; + for (const key in value) { + result[key] = unwrapRefs(value[key] as T); + } + return result as UnwrapRefs; +}; + +export const serializeBody = ( + opts: Pick[0], 'body' | 'bodySerializer'>, +) => { + if (opts.body && opts.bodySerializer) { + return opts.bodySerializer(opts.body); + } + return opts.body; +}; + +export const executeFetchFn = ( + opts: Omit[0], 'composable'>, + fetchFn: Required['$fetch'], +) => { + const unwrappedOpts = unwrapRefs(opts); + unwrappedOpts.rawBody = unwrappedOpts.body; + unwrappedOpts.body = serializeBody(unwrappedOpts); + return fetchFn( + buildUrl(opts), + // @ts-expect-error + unwrappedOpts, + ); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdk.gen.ts new file mode 100644 index 000000000..c9c9a0d67 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, 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'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const callWithDefaultParameters = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-extreme/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/client.gen.ts new file mode 100644 index 000000000..f9fd67a26 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/client.gen.ts @@ -0,0 +1,233 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { + useAsyncData, + useFetch, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import { reactive, ref, watch } from 'vue'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + executeFetchFn, + mergeConfigs, + mergeHeaders, + mergeInterceptors, + serializeBody, + setAuthParams, + unwrapRefs, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = ({ + asyncDataOptions, + composable = '$fetch', + ...options + }) => { + const key = options.key; + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + const { + requestValidator, + responseTransformer, + responseValidator, + security, + } = opts; + if (requestValidator || security) { + // auth must happen in interceptors otherwise we'd need to require + // asyncContext enabled + // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext + opts.onRequest = [ + async ({ options }) => { + if (security) { + await setAuthParams({ + auth: opts.auth, + headers: options.headers, + query: options.query, + security, + }); + } + + if (requestValidator) { + await requestValidator({ + ...options, + // @ts-expect-error + body: options.rawBody, + }); + } + }, + ...opts.onRequest, + ]; + } + + if (responseTransformer || responseValidator) { + opts.onResponse = [ + ...opts.onResponse, + async ({ options, response }) => { + if (options.responseType && options.responseType !== 'json') { + return; + } + + if (!response.ok) { + return; + } + + if (responseValidator) { + await responseValidator(response._data); + } + + if (responseTransformer) { + response._data = await responseTransformer(response._data); + } + }, + ]; + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.body === '') { + opts.headers.delete('Content-Type'); + } + + const fetchFn = opts.$fetch; + + if (composable === '$fetch') { + return executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + } + + if (composable === 'useFetch' || composable === 'useLazyFetch') { + opts.rawBody = opts.body; + const bodyParams = reactive({ + body: opts.body, + bodySerializer: opts.bodySerializer, + }); + const body = ref(serializeBody(opts)); + opts.body = body; + watch(bodyParams, (changed) => { + body.value = serializeBody(changed); + }); + return composable === 'useLazyFetch' + ? useLazyFetch(() => buildUrl(opts), opts) + : useFetch(() => buildUrl(opts), opts); + } + + const handler: any = () => + executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + + if (composable === 'useAsyncData') { + return key + ? useAsyncData(key, handler, asyncDataOptions) + : useAsyncData(handler, asyncDataOptions); + } + + if (composable === 'useLazyAsyncData') { + return key + ? useLazyAsyncData(key, handler, asyncDataOptions) + : useLazyAsyncData(handler, asyncDataOptions); + } + + return undefined as any; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...unwrapRefs(opts), + body: opts.body as BodyInit | null | undefined, + method, + onRequest: undefined, + signal: unwrapRefs(opts.signal) as AbortSignal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/index.ts new file mode 100644 index 000000000..a2e8f2493 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/index.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Composable, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/types.gen.ts new file mode 100644 index 000000000..ac663764d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AsyncDataOptions, + useAsyncData, + useFetch, + UseFetchOptions, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import type { Ref } from 'vue'; + +import type { Auth } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; +type ObjectStyle = 'form' | 'deepObject'; + +export type QuerySerializer = ( + query: Parameters[0]['query'], +) => string; + +type WithRefs = { + [K in keyof TData]: NonNullable extends object + ? WithRefs> | Ref> + : NonNullable | Ref>; +}; + +// copied from Nuxt +export type KeysOf = Array< + T extends T ? (keyof T extends string ? keyof T : never) : never +>; + +export interface Config + extends Omit< + FetchOptions, + 'baseURL' | 'body' | 'headers' | 'method' | 'query' + >, + WithRefs, 'query'>>, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; +} + +export interface RequestOptions< + TComposable extends Composable = '$fetch', + ResT = unknown, + DefaultT = undefined, + Url extends string = string, +> extends Config, + WithRefs<{ + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + rawBody?: unknown; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + asyncDataOptions?: AsyncDataOptions, DefaultT>; + composable?: TComposable; + key?: string; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export type RequestResult< + TComposable extends Composable, + ResT, + TError, +> = TComposable extends '$fetch' + ? ReturnType> + : TComposable extends 'useAsyncData' + ? ReturnType> + : TComposable extends 'useFetch' + ? ReturnType> + : TComposable extends 'useLazyAsyncData' + ? ReturnType> + : TComposable extends 'useLazyFetch' + ? ReturnType> + : never; + +export interface ClientOptions { + baseURL?: string; +} + +type MethodFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => Promise>>; + +type RequestFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + url: string; +} + +export type BuildUrlOptions< + TData extends Omit = Omit, +> = Pick, 'path' | 'query'> & + Pick & + Pick, 'baseURL' | 'querySerializer'>; + +type BuildUrlFn = >( + options: BuildUrlOptions, +) => string; + +export type Client = CoreClient; + +type OmitKeys = Pick>; + +export type Options< + TComposable extends Composable = '$fetch', + TData extends TDataShape = TDataShape, + ResT = unknown, + DefaultT = undefined, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + WithRefs>; + +export type OptionsLegacyParser = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys & TData + : OmitKeys & + TData & + Pick + : TData extends { headers?: any } + ? OmitKeys & + TData & + Pick + : OmitKeys & TData; + +type FetchOptions = Omit< + UseFetchOptions, + keyof AsyncDataOptions +>; + +export type Composable = + | '$fetch' + | 'useAsyncData' + | 'useFetch' + | 'useLazyAsyncData' + | 'useLazyFetch'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/utils.gen.ts new file mode 100644 index 000000000..0a1d343e2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/client/utils.gen.ts @@ -0,0 +1,389 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ComputedRef, Ref } from 'vue'; +import { isRef, toValue, unref } from 'vue'; + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { + ArraySeparatorStyle, + BuildUrlOptions, + Client, + ClientOptions, + Config, + QuerySerializer, + RequestOptions, +} from './types.gen'; + +type PathSerializer = Pick, 'path' | 'url'>; + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type MaybeArray = T | T[]; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = toValue(toValue(path)[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + const qParams = toValue(queryParams); + if (qParams && typeof qParams === 'object') { + for (const name in qParams) { + const value = toValue(qParams[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + toValue(options.query)?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + toValue(options.query)[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: Pick & { + baseUrl?: string; + querySerializer: QuerySerializer; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseURL?.endsWith('/')) { + config.baseURL = config.baseURL.substring(0, config.baseURL.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + let h: unknown = header; + if (isRef(h)) { + h = unref(h); + } + + const iterator = + h instanceof Headers + ? headersEntries(h) + : Object.entries(h as Record); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, unwrapRefs(v) as string); + } + } else if (value !== undefined) { + const v = unwrapRefs(value); + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof v === 'object' ? JSON.stringify(v) : (v as string), + ); + } + } + } + return mergedHeaders; +}; + +export const mergeInterceptors = (...args: Array>): Array => + args.reduce>((acc, item) => { + if (typeof item === 'function') { + acc.push(item); + } else if (Array.isArray(item)) { + return acc.concat(item); + } + return acc; + }, []); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); + +type UnwrapRefs = + T extends Ref + ? V + : T extends ComputedRef + ? V + : T extends Record // this doesn't handle functions well + ? { [K in keyof T]: UnwrapRefs } + : T; + +export const unwrapRefs = (value: T): UnwrapRefs => { + if (value === null || typeof value !== 'object' || value instanceof Headers) { + return (isRef(value) ? unref(value) : value) as UnwrapRefs; + } + + if (Array.isArray(value)) { + return value.map((item) => unwrapRefs(item)) as UnwrapRefs; + } + + if (isRef(value)) { + return unwrapRefs(unref(value) as T); + } + + // unwrap into new object to avoid modifying the source + const result: Record = {}; + for (const key in value) { + result[key] = unwrapRefs(value[key] as T); + } + return result as UnwrapRefs; +}; + +export const serializeBody = ( + opts: Pick[0], 'body' | 'bodySerializer'>, +) => { + if (opts.body && opts.bodySerializer) { + return opts.bodySerializer(opts.body); + } + return opts.body; +}; + +export const executeFetchFn = ( + opts: Omit[0], 'composable'>, + fetchFn: Required['$fetch'], +) => { + const unwrappedOpts = unwrapRefs(opts); + unwrappedOpts.rawBody = unwrappedOpts.body; + unwrappedOpts.body = serializeBody(unwrappedOpts); + return fetchFn( + buildUrl(opts), + // @ts-expect-error + unwrappedOpts, + ); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdk.gen.ts new file mode 100644 index 000000000..be2e811a1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdk.gen.ts @@ -0,0 +1,657 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, 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'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { zExportData, zPatchApiVbyApiVersionNoTagData, zImportData, zImportResponse, zFooWowData, zApiVVersionODataControllerCountData, zApiVVersionODataControllerCountResponse, zGetApiVbyApiVersionSimpleOperationData, zGetApiVbyApiVersionSimpleOperationResponse, zDeleteCallWithoutParametersAndResponseData, zGetCallWithoutParametersAndResponseData, zHeadCallWithoutParametersAndResponseData, zOptionsCallWithoutParametersAndResponseData, zPatchCallWithoutParametersAndResponseData, zPostCallWithoutParametersAndResponseData, zPutCallWithoutParametersAndResponseData, zDeleteFooData3 as zDeleteFooData, zCallWithDescriptionsData, zDeprecatedCallData, zCallWithParametersData, zCallWithWeirdParameterNamesData, zGetCallWithOptionalParamData, zPostCallWithOptionalParamData, zPostCallWithOptionalParamResponse, zPostApiVbyApiVersionRequestBodyData, zPostApiVbyApiVersionFormDataData, zCallWithDefaultParametersData, zCallWithDefaultOptionalParametersData, zCallToTestOrderOfParamsData, zDuplicateNameData, zDuplicateName2Data, zDuplicateName3Data, zDuplicateName4Data, zCallWithNoContentResponseData, zCallWithNoContentResponseResponse, zCallWithResponseAndNoContentResponseData, zCallWithResponseAndNoContentResponseResponse, zDummyAData, zDummyAResponse, zDummyBData, zDummyBResponse, zCallWithResponseData, zCallWithResponseResponse, zCallWithDuplicateResponsesData, zCallWithDuplicateResponsesResponse, zCallWithResponsesData, zCallWithResponsesResponse, zCollectionFormatData, zTypesData, zTypesResponse, zUploadFileData, zUploadFileResponse, zFileResponseData, zFileResponseResponse, zComplexTypesData, zComplexTypesResponse, zMultipartResponseData, zMultipartResponseResponse, zMultipartRequestData, zComplexParamsData, zComplexParamsResponse, zCallWithResultFromHeaderData, zTestErrorCodeData, zNonAsciiæøåÆøÅöôêÊ字符串Data, zNonAsciiæøåÆøÅöôêÊ字符串Response, zPutWithFormUrlEncodedData } from './zod.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + requestValidator: async (data) => { + return await zExportData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchApiVbyApiVersionNoTagData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + requestValidator: async (data) => { + return await zImportData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zImportResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + requestValidator: async (data) => { + return await zFooWowData.parseAsync(data); + }, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + requestValidator: async (data) => { + return await zApiVVersionODataControllerCountData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zApiVVersionODataControllerCountResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + requestValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zGetApiVbyApiVersionSimpleOperationResponse.parseAsync(data); + }, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zHeadCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zOptionsCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPatchCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zPutCallWithoutParametersAndResponseData.parseAsync(data); + }, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + requestValidator: async (data) => { + return await zDeleteFooData.parseAsync(data); + }, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDescriptionsData.parseAsync(data); + }, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + requestValidator: async (data) => { + return await zDeprecatedCallData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithWeirdParameterNamesData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zGetCallWithOptionalParamData.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + requestValidator: async (data) => { + return await zPostCallWithOptionalParamData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zPostCallWithOptionalParamResponse.parseAsync(data); + }, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionRequestBodyData.parseAsync(data); + }, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + requestValidator: async (data) => { + return await zPostApiVbyApiVersionFormDataData.parseAsync(data); + }, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const callWithDefaultParameters = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDefaultOptionalParametersData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zCallToTestOrderOfParamsData.parseAsync(data); + }, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateNameData.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName2Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName3Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + requestValidator: async (data) => { + return await zDuplicateName4Data.parseAsync(data); + }, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseAndNoContentResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + requestValidator: async (data) => { + return await zDummyAData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyAResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + requestValidator: async (data) => { + return await zDummyBData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zDummyBResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithDuplicateResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithDuplicateResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResponsesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zCallWithResponsesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + requestValidator: async (data) => { + return await zCollectionFormatData.parseAsync(data); + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + requestValidator: async (data) => { + return await zTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + requestValidator: async (data) => { + return await zUploadFileData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zUploadFileResponse.parseAsync(data); + }, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zFileResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zFileResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexTypesData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexTypesResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartResponseData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zMultipartResponseResponse.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + requestValidator: async (data) => { + return await zMultipartRequestData.parseAsync(data); + }, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + requestValidator: async (data) => { + return await zComplexParamsData.parseAsync(data); + }, + responseValidator: async (data) => { + return await zComplexParamsResponse.parseAsync(data); + }, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + requestValidator: async (data) => { + return await zCallWithResultFromHeaderData.parseAsync(data); + }, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + requestValidator: async (data) => { + return await zTestErrorCodeData.parseAsync(data); + }, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + requestValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Data.parseAsync(data); + }, + responseValidator: async (data) => { + return await zNonAsciiæøåÆøÅöôêÊ字符串Response.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + requestValidator: async (data) => { + return await zPutWithFormUrlEncodedData.parseAsync(data); + }, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/zod.gen.ts new file mode 100644 index 000000000..a08796446 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing-zod/zod.gen.ts @@ -0,0 +1,1790 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +/** + * Model with number-only name + */ +export const z400 = z.string(); + +export const zExternalSharedExternalSharedModel = z.object({ + id: z.string(), + name: z.optional(z.string()) +}); + +/** + * External ref to shared model (A) + */ +export const zExternalRefA = zExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export const zExternalRefB = zExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCamelCaseCommentWithBreaks = z.int(); + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export const zCommentWithBreaks = z.int(); + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export const zCommentWithBackticks = z.int(); + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export const zCommentWithBackticksAndQuotes = z.int(); + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export const zCommentWithSlashes = z.int(); + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export const zCommentWithExpressionPlaceholders = z.int(); + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export const zCommentWithQuotes = z.int(); + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export const zCommentWithReservedCharacters = z.int(); + +/** + * This is a simple number + */ +export const zSimpleInteger = z.int(); + +/** + * This is a simple boolean + */ +export const zSimpleBoolean = z.boolean(); + +/** + * This is a simple string + */ +export const zSimpleString = z.string(); + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); + +/** + * This is a simple file + */ +export const zSimpleFile = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithString = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a simple reference + */ +export const zSimpleReference = zModelWithString; + +/** + * This is a simple string + */ +export const zSimpleStringWithPattern = z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + z.null() +]); + +/** + * This is a simple enum with strings + */ +export const zEnumWithStrings = z.enum([ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串' +]); + +export const zEnumWithReplacedCharacters = z.enum([ + "'Single Quote'", + '"Double Quotes"', + 'øæåôöØÆÅÔÖ字符串', + '' +]); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithNumbers = z.unknown(); + +/** + * Success=1,Warning=2,Error=3 + */ +export const zEnumFromDescription = z.number(); + +/** + * This is a simple enum with numbers + */ +export const zEnumWithExtensions = z.unknown(); + +export const zEnumWithXEnumNames = z.unknown(); + +/** + * This is a simple array with numbers + */ +export const zArrayWithNumbers = z.array(z.int()); + +/** + * This is a simple array with booleans + */ +export const zArrayWithBooleans = z.array(z.boolean()); + +/** + * This is a simple array with strings + */ +export const zArrayWithStrings = z.array(z.string()).default(['test']); + +/** + * This is a simple array with references + */ +export const zArrayWithReferences = z.array(zModelWithString); + +/** + * This is a simple array containing an array + */ +export const zArrayWithArray = z.array(z.array(zModelWithString)); + +/** + * This is a simple array with properties + */ +export const zArrayWithProperties = z.array(z.object({ + '16x16': z.optional(zCamelCaseCommentWithBreaks), + bar: z.optional(z.string()) +})); + +/** + * This is a simple array with any of properties + */ +export const zArrayWithAnyOfProperties = z.array(z.union([ + z.object({ + foo: z.optional(z.string()).default('test') + }), + z.object({ + bar: z.optional(z.string()) + }) +])); + +export const zAnyOfAnyAndNull = z.object({ + data: z.optional(z.union([ + z.unknown(), + z.null() + ])) +}); + +/** + * This is a simple array with any of properties + */ +export const zAnyOfArrays = z.object({ + results: z.optional(z.array(z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.object({ + bar: z.optional(z.string()) + }) + ]))) +}); + +/** + * This is a string dictionary + */ +export const zDictionaryWithString = z.record(z.string(), z.string()); + +export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ + foo: z.optional(z.number()), + bar: z.optional(z.boolean()) +}); + +/** + * This is a string reference + */ +export const zDictionaryWithReference = z.record(z.string(), zModelWithString); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); + +/** + * This is a string dictionary + */ +export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); + +/** + * This is a complex dictionary + */ +export const zDictionaryWithProperties = z.record(z.string(), z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) +})); + +/** + * This is a model with one number property + */ +export const zModelWithInteger = z.object({ + prop: z.optional(z.int()) +}); + +/** + * This is a model with one boolean property + */ +export const zModelWithBoolean = z.object({ + prop: z.optional(z.boolean()) +}); + +/** + * This is a model with one string property + */ +export const zModelWithStringError = z.object({ + prop: z.optional(z.string()) +}); + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export const zModelFromZendesk = z.string(); + +/** + * This is a model with one string property + */ +export const zModelWithNullableString = z.object({ + nullableProp1: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp1: z.union([ + z.string(), + z.null() + ]), + nullableProp2: z.optional(z.union([ + z.string(), + z.null() + ])), + nullableRequiredProp2: z.union([ + z.string(), + z.null() + ]), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnum = z.object({ + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])), + statusCode: z.optional(z.enum([ + '100', + '200 FOO', + '300 FOO_BAR', + '400 foo-bar', + '500 foo.bar', + '600 foo&bar' + ])), + bool: z.optional(z.unknown()) +}); + +/** + * This is a model with one enum with escaped name + */ +export const zModelWithEnumWithHyphen = z.object({ + 'foo-bar-baz-qux': z.optional(z.enum([ + '3.0' + ])) +}); + +/** + * This is a model with one enum + */ +export const zModelWithEnumFromDescription = z.object({ + test: z.optional(z.int()) +}); + +/** + * This is a model with nested enums + */ +export const zModelWithNestedEnums = z.object({ + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), + arrayWithEnum: z.optional(z.array(z.enum([ + 'Success', + 'Warning', + 'Error' + ]))), + arrayWithDescription: z.optional(z.array(z.int())), + 'foo_bar-enum': z.optional(z.enum([ + 'Success', + 'Warning', + 'Error', + 'ØÆÅ字符串' + ])) +}); + +/** + * This is a model with one nested property + */ +export const zModelWithProperties = z.object({ + required: z.string(), + requiredAndReadOnly: z.string().readonly(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()), + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()) +}); + +/** + * This is a model with one property containing a reference + */ +export const zModelWithReference = z.object({ + prop: z.optional(zModelWithProperties) +}); + +export const zModelWithReadOnlyAndWriteOnly = z.object({ + foo: z.string(), + bar: z.string().readonly() +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing an array + */ +export const zModelWithArray = z.object({ + prop: z.optional(z.array(zModelWithString)), + propWithFile: z.optional(z.array(z.string())), + propWithNumber: z.optional(z.array(z.number())) +}); + +/** + * This is a model with one property containing a dictionary + */ +export const zModelWithDictionary = z.object({ + prop: z.optional(z.record(z.string(), z.string())) +}); + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export const zDeprecatedModel = z.object({ + prop: z.optional(z.string()) +}); + +/** + * This is a model with one property containing a circular reference + */ +export const zModelWithCircularReference = z.object({ + get prop(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zModelWithCircularReference; + })); + } +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * Circle + */ +export const zModelCircle = z.object({ + kind: z.string(), + radius: z.optional(z.number()) +}); + +/** + * Square + */ +export const zModelSquare = z.object({ + kind: z.string(), + sideLength: z.optional(z.number()) +}); + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export const zCompositionWithOneOfDiscriminator = z.union([ + z.object({ + kind: z.literal('circle') + }).and(zModelCircle), + z.object({ + kind: z.literal('square') + }).and(zModelSquare) +]); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOf = z.object({ + propA: z.optional(z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithAnyOfAnonymous = z.object({ + propA: z.optional(z.union([ + z.object({ + propA: z.optional(z.string()) + }), + z.string(), + z.int() + ])) +}); + +/** + * This is a model with nested 'any of' property with a type null + */ +export const zCompositionWithNestedAnyAndTypeNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + zModelWithDictionary, + z.null() + ])), + z.array(z.union([ + zModelWithArray, + z.null() + ])) + ])) +}); + +export const z3eNum1Период = z.enum([ + 'Bird', + 'Dog' +]); + +export const zConstValue = z.literal('ConstValue'); + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export const zCompositionWithNestedAnyOfAndNull = z.object({ + propA: z.optional(z.union([ + z.array(z.union([ + z3eNum1Период, + zConstValue + ])), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'one of' relationship + */ +export const zCompositionWithOneOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a model that contains a simple dictionary within composition + */ +export const zCompositionWithOneOfAndSimpleDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.number()) + ])) +}); + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.boolean())) + ])) +}); + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ + propA: z.optional(z.union([ + z.boolean(), + z.record(z.string(), z.array(z.union([ + z.number(), + z.string() + ]))) + ])) +}); + +/** + * This is a model with one property with a 'all of' relationship + */ +export const zCompositionWithAllOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), + z.null() + ])) +}); + +/** + * This is a model with one property with a 'any of' relationship + */ +export const zCompositionWithAnyOfAndNullable = z.object({ + propA: z.optional(z.union([ + z.object({ + boolean: z.optional(z.boolean()) + }), + zModelWithEnum, + zModelWithArray, + zModelWithDictionary, + z.null() + ])) +}); + +/** + * This is a base model with two simple optional properties + */ +export const zCompositionBaseModel = z.object({ + firstName: z.optional(z.string()), + lastname: z.optional(z.string()) +}); + +/** + * This is a model that extends the base model + */ +export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ + age: z.number(), + firstName: z.string(), + lastname: z.string() +})); + +/** + * This is a model with one nested property + */ +export const zModelWithNestedProperties = z.object({ + first: z.union([ + z.object({ + second: z.union([ + z.object({ + third: z.union([ + z.string().readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() + }).readonly(), + z.null() + ]).readonly() +}); + +/** + * This is a model with duplicated properties + */ +export const zModelWithDuplicateProperties = z.object({ + prop: z.optional(zModelWithString) +}); + +/** + * This is a model with ordered properties + */ +export const zModelWithOrderedProperties = z.object({ + zebra: z.optional(z.string()), + apple: z.optional(z.string()), + hawaii: z.optional(z.string()) +}); + +/** + * This is a model with duplicated imports + */ +export const zModelWithDuplicateImports = z.object({ + propA: z.optional(zModelWithString), + propB: z.optional(zModelWithString), + propC: z.optional(zModelWithString) +}); + +/** + * This is a model that extends another model + */ +export const zModelThatExtends = zModelWithString.and(z.object({ + propExtendsA: z.optional(z.string()), + propExtendsB: z.optional(zModelWithString) +})); + +/** + * This is a model that extends another model + */ +export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ + propExtendsC: z.optional(z.string()), + propExtendsD: z.optional(zModelWithString) +})); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPattern = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + enabled: z.optional(z.boolean().readonly()), + modified: z.optional(z.iso.datetime().readonly()), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFile = z.object({ + id: z.optional(z.string().min(1).readonly()), + updated_at: z.optional(z.iso.datetime().readonly()), + created_at: z.optional(z.iso.datetime().readonly()), + mime: z.string().min(1).max(24), + file: z.optional(z.url().readonly()) +}); + +export const zDefault = z.object({ + name: z.optional(z.string()) +}); + +export const zPageable = z.object({ + page: z.optional(z.int().gte(0)).default(0), + size: z.optional(z.int().gte(1)), + sort: z.optional(z.array(z.string())) +}); + +/** + * This is a free-form object without additionalProperties. + */ +export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: true. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); + +/** + * This is a free-form object with additionalProperties: {}. + */ +export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); + +export const zModelWithConst = z.object({ + String: z.optional(z.literal('String')), + number: z.optional(z.literal(0)), + null: z.optional(z.null()), + withType: z.optional(z.literal('Some string')) +}); + +/** + * This is a model with one property and additionalProperties: true + */ +export const zModelWithAdditionalPropertiesEqTrue = z.object({ + prop: z.optional(z.string()) +}); + +export const zNestedAnyOfArraysNullable = z.object({ + nullableArray: z.optional(z.union([ + z.array(z.union([ + z.string(), + z.boolean() + ])), + z.null() + ])) +}); + +/** + * This is a reusable parameter + */ +export const zSimpleParameter = z.unknown(); + +export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ + z.object({ + foo: zSimpleParameter + }), + z.object({ + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 + }) +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * An object that can be null + */ +export const zNullableObject = z.union([ + z.object({ + foo: z.optional(z.string()) + }), + z.null() +]).default(null); + +/** + * Some % character + */ +export const zCharactersInDescription = z.string(); + +export const zModelWithNullableObject = z.object({ + data: z.optional(zNullableObject) +}); + +export const zModelWithOneOfEnum = z.union([ + z.object({ + foo: z.enum([ + 'Bar' + ]) + }), + z.object({ + foo: z.enum([ + 'Baz' + ]) + }), + z.object({ + foo: z.enum([ + 'Qux' + ]) + }), + z.object({ + content: z.iso.datetime(), + foo: z.enum([ + 'Quux' + ]) + }), + z.object({ + content: z.tuple([ + z.iso.datetime(), + z.string() + ]), + foo: z.enum([ + 'Corge' + ]) + }) +]); + +export const zModelWithNestedArrayEnumsDataFoo = z.enum([ + 'foo', + 'bar' +]); + +export const zModelWithNestedArrayEnumsDataBar = z.enum([ + 'baz', + 'qux' +]); + +export const zModelWithNestedArrayEnumsData = z.object({ + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) +}); + +export const zModelWithNestedArrayEnums = z.object({ + array_strings: z.optional(z.array(z.string())), + data: z.optional(zModelWithNestedArrayEnumsData) +}); + +export const zModelWithNestedCompositionEnums = z.object({ + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) +}); + +export const zModelWithConstantSizeArray = z.tuple([ + z.number(), + z.number() +]); + +export const zModelWithAnyOfConstantSizeArray = z.tuple([ + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]), + z.union([ + z.number(), + z.string() + ]) +]); + +export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ + zModelWithInteger, + z.union([ + z.number(), + z.string() + ]), + z.string() +]); + +export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]), + z.union([ + z.number(), + z.null(), + z.string() + ]) +]); + +/** + * Model with restricted keyword name + */ +export const zImport = z.string(); + +export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ + z.union([ + z.number(), + zImport + ]), + z.union([ + z.number(), + zImport + ]) +]); + +export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ + z.intersection(z.number(), z.string()), + z.intersection(z.number(), z.string()) +]); + +export const zModelWithNumericEnumUnion = z.object({ + value: z.optional(z.unknown()) +}); + +/** + * Some description with `back ticks` + */ +export const zModelWithBackticksInDescription = z.object({ + template: z.optional(z.string()) +}); + +export const zModelWithOneOfAndProperties = z.intersection(z.union([ + zSimpleParameter, + zNonAsciiStringæøåÆøÅöôêÊ字符串 +]), z.object({ + baz: z.union([ + z.int().gte(0), + z.null() + ]), + qux: z.int().gte(0) +})); + +/** + * Model used to test deduplication strategy (unused) + */ +export const zParameterSimpleParameterUnused = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zPostServiceWithEmptyTagResponse2 = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData = z.string(); + +/** + * Model used to test deduplication strategy + */ +export const zDeleteFooData2 = z.string(); + +export const zSchemaWithFormRestrictedKeys = z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()), + object: z.optional(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + })), + array: z.optional(z.array(z.object({ + description: z.optional(z.string()), + 'x-enum-descriptions': z.optional(z.string()), + 'x-enum-varnames': z.optional(z.string()), + 'x-enumNames': z.optional(z.string()), + title: z.optional(z.string()) + }))) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ + resourceVersion: z.optional(z.string()), + uid: z.optional(z.string()) +}); + +/** + * This schema was giving PascalCase transformations a hard time + */ +export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) +}); + +export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) +})); + +export const zAdditionalPropertiesIntegerIssue = z.object({ + value: z.int() +}); + +export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemString = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + hasError: z.optional(z.boolean().readonly()) +}); + +export const zOneOfAllOfIssue = z.union([ + z.intersection(z.union([ + zConstValue, + zGenericSchemaDuplicateIssue1SystemBoolean + ]), z3eNum1Период), + zGenericSchemaDuplicateIssue1SystemString +]); + +/** + * This is a model with one nested property + */ +export const zModelWithPropertiesWritable = z.object({ + required: z.string(), + requiredAndNullable: z.union([ + z.string(), + z.null() + ]), + string: z.optional(z.string()), + number: z.optional(z.number()), + boolean: z.optional(z.boolean()), + reference: z.optional(zModelWithString), + 'property with space': z.optional(z.string()), + default: z.optional(z.string()), + try: z.optional(z.string()) +}); + +/** + * This is a model that contains a some patterns + */ +export const zModelWithPatternWritable = z.object({ + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), + name: z.string().max(255), + id: z.optional(z.string().regex(/^\d{2}-\d{3}-\d{4}$/)), + text: z.optional(z.string().regex(/^\w+$/)), + patternWithSingleQuotes: z.optional(z.string().regex(/^[a-zA-Z0-9']*$/)), + patternWithNewline: z.optional(z.string().regex(/aaa\nbbb/)), + patternWithBacktick: z.optional(z.string().regex(/aaa`bbb/)) +}); + +export const zFileWritable = z.object({ + mime: z.string().min(1).max(24) +}); + +export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ + foo: z.string(), + baz: z.string() +}); + +export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ + z.string(), + z.number() +])); + +export const zGenericSchemaDuplicateIssue1SystemBooleanWritable = z.object({ + item: z.optional(z.boolean()), + error: z.optional(z.union([ + z.string(), + z.null() + ])), + data: z.optional(z.record(z.string(), z.never())) +}); + +export const zGenericSchemaDuplicateIssue1SystemStringWritable = z.object({ + item: z.optional(z.union([ + z.string(), + z.null() + ])), + error: z.optional(z.union([ + z.string(), + z.null() + ])) +}); + +/** + * Parameter with illegal characters + */ +export const zXFooBar = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleRequestBody = zModelWithString; + +/** + * A reusable request body + */ +export const zSimpleFormData = zModelWithString; + +export const zExportData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchApiVbyApiVersionNoTagData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportData = z.object({ + body: z.union([ + zModelWithReadOnlyAndWriteOnlyWritable, + zModelWithArrayReadOnlyAndWriteOnly + ]), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zImportResponse = z.union([ + zModelFromZendesk, + zModelWithReadOnlyAndWriteOnly +]); + +export const zFooWowData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zApiVVersionODataControllerCountData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; + +export const zGetApiVbyApiVersionSimpleOperationData = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.union([ + z.string(), + z.uuid() + ]) + }), + query: z.optional(z.never()) +}); + +/** + * Response is a simple number + */ +export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); + +export const zDeleteCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zGetCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zHeadCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zOptionsCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPatchCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPostCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zPutCallWithoutParametersAndResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDeleteFooData3 = z.object({ + body: z.optional(z.never()), + path: z.object({ + foo_param: z.string(), + BarParam: z.string() + }), + query: z.optional(z.never()), + headers: z.object({ + 'x-Foo-Bar': zModelWithString + }) +}); + +export const zCallWithDescriptionsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterWithBreaks: z.optional(z.string()), + parameterWithBackticks: z.optional(z.string()), + parameterWithSlashes: z.optional(z.string()), + parameterWithExpressionPlaceholders: z.optional(z.string()), + parameterWithQuotes: z.optional(z.string()), + parameterWithReservedCharacters: z.optional(z.string()) + })) +}); + +export const zDeprecatedCallData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()), + headers: z.object({ + parameter: z.union([ + zDeprecatedModel, + z.null() + ]) + }) +}); + +export const zCallWithParametersData = z.object({ + body: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + path: z.object({ + parameterPath: z.union([ + z.string(), + z.null() + ]), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFoo), + foo_all_of_enum: zModelWithNestedArrayEnumsDataFoo, + cursor: z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + parameterHeader: z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zCallWithWeirdParameterNamesData = z.object({ + body: z.union([ + zModelWithString, + z.null() + ]), + path: z.object({ + 'parameter.path.1': z.optional(z.string()), + 'parameter-path-2': z.optional(z.string()), + 'PARAMETER-PATH-3': z.optional(z.string()), + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.object({ + default: z.optional(z.string()), + 'parameter-query': z.union([ + z.string(), + z.null() + ]) + }), + headers: z.object({ + 'parameter.header': z.union([ + z.string(), + z.null() + ]) + }) +}); + +export const zGetCallWithOptionalParamData = z.object({ + body: zModelWithOneOfEnum, + path: z.optional(z.never()), + query: z.optional(z.object({ + page: z.optional(z.number()) + })) +}); + +export const zPostCallWithOptionalParamData = z.object({ + body: z.optional(z.object({ + offset: z.optional(z.union([ + z.number(), + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.object({ + parameter: zPageable + }) +}); + +export const zPostCallWithOptionalParamResponse = z.union([ + z.number(), + z.void() +]); + +export const zPostApiVbyApiVersionRequestBodyData = z.object({ + body: z.optional(zSimpleRequestBody), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zPostApiVbyApiVersionFormDataData = z.object({ + body: z.optional(zSimpleFormData), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameter: z.optional(z.string()) + })) +}); + +export const zCallWithDefaultParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.union([ + z.string().default('Hello World!'), + z.null() + ])).default('Hello World!'), + parameterNumber: z.optional(z.union([ + z.number().default(123), + z.null() + ])).default(123), + parameterBoolean: z.optional(z.union([ + z.boolean().default(true), + z.null() + ])).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })) +}); + +export const zCallWithDefaultOptionalParametersData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.object({ + parameterString: z.optional(z.string()).default('Hello World!'), + parameterNumber: z.optional(z.number()).default(123), + parameterBoolean: z.optional(z.boolean()).default(true), + parameterEnum: z.optional(z.enum([ + 'Success', + 'Warning', + 'Error' + ])), + parameterModel: z.optional(zModelWithString) + })) +}); + +export const zCallToTestOrderOfParamsData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterOptionalStringWithDefault: z.optional(z.string()).default('Hello World!'), + parameterOptionalStringWithEmptyDefault: z.optional(z.string()).default(''), + parameterOptionalStringWithNoDefault: z.optional(z.string()), + parameterStringWithDefault: z.string().default('Hello World!'), + parameterStringWithEmptyDefault: z.string().default(''), + parameterStringWithNoDefault: z.string(), + parameterStringNullableWithNoDefault: z.optional(z.union([ + z.string(), + z.null() + ])), + parameterStringNullableWithDefault: z.optional(z.union([ + z.string(), + z.null() + ])).default(null) + }) +}); + +export const zDuplicateNameData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName2Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName3Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDuplicateName4Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zCallWithNoContentResponseResponse = z.void(); + +export const zCallWithResponseAndNoContentResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseAndNoContentResponseResponse = z.union([ + z.number(), + z.void() +]); + +export const zDummyAData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zDummyAResponse = z400; + +export const zDummyBData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zDummyBResponse = z.void(); + +export const zCallWithResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponseResponse = zImport; + +export const zCallWithDuplicateResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithDuplicateResponsesResponse = z.union([ + zModelWithBoolean.and(zModelWithInteger), + zModelWithString +]); + +export const zCallWithResponsesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zCallWithResponsesResponse = z.union([ + z.object({ + '@namespace.string': z.optional(z.string().readonly()), + '@namespace.integer': z.optional(z.int().readonly()), + value: z.optional(z.array(zModelWithString).readonly()) + }), + zModelThatExtends, + zModelThatExtendsExtends +]); + +export const zCollectionFormatData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterArrayCSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArraySSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayTSV: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayPipes: z.union([ + z.array(z.string()), + z.null() + ]), + parameterArrayMulti: z.union([ + z.array(z.string()), + z.null() + ]) + }) +}); + +export const zTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.object({ + id: z.optional(z.int()) + })), + query: z.object({ + parameterNumber: z.number().default(123), + parameterString: z.union([ + z.string().default('default'), + z.null() + ]).default('default'), + parameterBoolean: z.union([ + z.boolean().default(true), + z.null() + ]).default(true), + parameterObject: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]).default(null), + parameterArray: z.union([ + z.array(z.string()), + z.null() + ]), + parameterDictionary: z.union([ + z.record(z.string(), z.unknown()), + z.null() + ]), + parameterEnum: z.union([ + z.literal('Success'), + z.literal('Warning'), + z.literal('Error'), + z.null() + ]) + }) +}); + +export const zTypesResponse = z.union([ + z.number(), + z.string(), + z.boolean(), + z.record(z.string(), z.unknown()) +]); + +export const zUploadFileData = z.object({ + body: z.string(), + path: z.object({ + 'api-version': z.union([ + z.string(), + z.null() + ]) + }), + query: z.optional(z.never()) +}); + +export const zUploadFileResponse = z.boolean(); + +export const zFileResponseData = z.object({ + body: z.optional(z.never()), + path: z.object({ + id: z.string(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zFileResponseResponse = z.string(); + +export const zComplexTypesData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + parameterObject: z.object({ + first: z.optional(z.object({ + second: z.optional(z.object({ + third: z.optional(z.string()) + })) + })) + }), + parameterReference: zModelWithString + }) +}); + +/** + * Successful response + */ +export const zComplexTypesResponse = z.array(zModelWithString); + +export const zMultipartResponseData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +/** + * OK + */ +export const zMultipartResponseResponse = z.object({ + file: z.optional(z.string()), + metadata: z.optional(z.object({ + foo: z.optional(z.string()), + bar: z.optional(z.string()) + })) +}); + +export const zMultipartRequestData = z.object({ + body: z.optional(z.object({ + content: z.optional(z.string()), + data: z.optional(z.union([ + zModelWithString, + z.null() + ])) + })), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zComplexParamsData = z.object({ + body: z.optional(z.object({ + key: z.union([ + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), + z.null() + ]).readonly(), + name: z.union([ + z.string().max(255), + z.null() + ]), + enabled: z.optional(z.boolean()).default(true), + type: z.enum([ + 'Monkey', + 'Horse', + 'Bird' + ]), + listOfModels: z.optional(z.union([ + z.array(zModelWithString), + z.null() + ])), + listOfStrings: z.optional(z.union([ + z.array(z.string()), + z.null() + ])), + parameters: z.union([ + zModelWithString, + zModelWithEnum, + zModelWithArray, + zModelWithDictionary + ]), + user: z.optional(z.object({ + id: z.optional(z.int().readonly()), + name: z.optional(z.union([ + z.string().readonly(), + z.null() + ]).readonly()) + }).readonly()) + })), + path: z.object({ + id: z.int(), + 'api-version': z.string() + }), + query: z.optional(z.never()) +}); + +/** + * Success + */ +export const zComplexParamsResponse = zModelWithString; + +export const zCallWithResultFromHeaderData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.optional(z.never()) +}); + +export const zTestErrorCodeData = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + status: z.int() + }) +}); + +export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ + body: z.optional(z.never()), + path: z.optional(z.never()), + query: z.object({ + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() + }) +}); + +/** + * Successful response + */ +export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); + +export const zPutWithFormUrlEncodedData = z.object({ + body: zArrayWithStrings, + path: z.optional(z.never()), + query: z.optional(z.never()) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client.gen.ts new file mode 100644 index 000000000..f46dd8f72 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig({ + baseURL: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/client.gen.ts new file mode 100644 index 000000000..f9fd67a26 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/client.gen.ts @@ -0,0 +1,233 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { + useAsyncData, + useFetch, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import { reactive, ref, watch } from 'vue'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import type { Client, Config, RequestOptions } from './types.gen'; +import { + buildUrl, + createConfig, + executeFetchFn, + mergeConfigs, + mergeHeaders, + mergeInterceptors, + serializeBody, + setAuthParams, + unwrapRefs, +} from './utils.gen'; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = ({ + asyncDataOptions, + composable = '$fetch', + ...options + }) => { + const key = options.key; + const opts = { + ..._config, + ...options, + $fetch: options.$fetch ?? _config.$fetch ?? $fetch, + headers: mergeHeaders(_config.headers, options.headers), + onRequest: mergeInterceptors(_config.onRequest, options.onRequest), + onResponse: mergeInterceptors(_config.onResponse, options.onResponse), + }; + + const { + requestValidator, + responseTransformer, + responseValidator, + security, + } = opts; + if (requestValidator || security) { + // auth must happen in interceptors otherwise we'd need to require + // asyncContext enabled + // https://nuxt.com/docs/guide/going-further/experimental-features#asynccontext + opts.onRequest = [ + async ({ options }) => { + if (security) { + await setAuthParams({ + auth: opts.auth, + headers: options.headers, + query: options.query, + security, + }); + } + + if (requestValidator) { + await requestValidator({ + ...options, + // @ts-expect-error + body: options.rawBody, + }); + } + }, + ...opts.onRequest, + ]; + } + + if (responseTransformer || responseValidator) { + opts.onResponse = [ + ...opts.onResponse, + async ({ options, response }) => { + if (options.responseType && options.responseType !== 'json') { + return; + } + + if (!response.ok) { + return; + } + + if (responseValidator) { + await responseValidator(response._data); + } + + if (responseTransformer) { + response._data = await responseTransformer(response._data); + } + }, + ]; + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.body === '') { + opts.headers.delete('Content-Type'); + } + + const fetchFn = opts.$fetch; + + if (composable === '$fetch') { + return executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + } + + if (composable === 'useFetch' || composable === 'useLazyFetch') { + opts.rawBody = opts.body; + const bodyParams = reactive({ + body: opts.body, + bodySerializer: opts.bodySerializer, + }); + const body = ref(serializeBody(opts)); + opts.body = body; + watch(bodyParams, (changed) => { + body.value = serializeBody(changed); + }); + return composable === 'useLazyFetch' + ? useLazyFetch(() => buildUrl(opts), opts) + : useFetch(() => buildUrl(opts), opts); + } + + const handler: any = () => + executeFetchFn( + // @ts-expect-error + opts, + fetchFn, + ); + + if (composable === 'useAsyncData') { + return key + ? useAsyncData(key, handler, asyncDataOptions) + : useAsyncData(handler, asyncDataOptions); + } + + if (composable === 'useLazyAsyncData') { + return key + ? useLazyAsyncData(key, handler, asyncDataOptions) + : useLazyAsyncData(handler, asyncDataOptions); + } + + return undefined as any; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...unwrapRefs(opts), + body: opts.body as BodyInit | null | undefined, + method, + onRequest: undefined, + signal: unwrapRefs(opts.signal) as AbortSignal, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/index.ts new file mode 100644 index 000000000..a2e8f2493 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/index.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Composable, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + TDataShape, +} from './types.gen'; +export { createConfig } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/types.gen.ts new file mode 100644 index 000000000..ac663764d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/types.gen.ts @@ -0,0 +1,216 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + AsyncDataOptions, + useAsyncData, + useFetch, + UseFetchOptions, + useLazyAsyncData, + useLazyFetch, +} from 'nuxt/app'; +import type { Ref } from 'vue'; + +import type { Auth } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; + +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; +type ObjectStyle = 'form' | 'deepObject'; + +export type QuerySerializer = ( + query: Parameters[0]['query'], +) => string; + +type WithRefs = { + [K in keyof TData]: NonNullable extends object + ? WithRefs> | Ref> + : NonNullable | Ref>; +}; + +// copied from Nuxt +export type KeysOf = Array< + T extends T ? (keyof T extends string ? keyof T : never) : never +>; + +export interface Config + extends Omit< + FetchOptions, + 'baseURL' | 'body' | 'headers' | 'method' | 'query' + >, + WithRefs, 'query'>>, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseURL?: T['baseURL']; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; +} + +export interface RequestOptions< + TComposable extends Composable = '$fetch', + ResT = unknown, + DefaultT = undefined, + Url extends string = string, +> extends Config, + WithRefs<{ + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + rawBody?: unknown; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + asyncDataOptions?: AsyncDataOptions, DefaultT>; + composable?: TComposable; + key?: string; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export type RequestResult< + TComposable extends Composable, + ResT, + TError, +> = TComposable extends '$fetch' + ? ReturnType> + : TComposable extends 'useAsyncData' + ? ReturnType> + : TComposable extends 'useFetch' + ? ReturnType> + : TComposable extends 'useLazyAsyncData' + ? ReturnType> + : TComposable extends 'useLazyFetch' + ? ReturnType> + : never; + +export interface ClientOptions { + baseURL?: string; +} + +type MethodFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'>, +) => Promise>>; + +type RequestFn = < + TComposable extends Composable = '$fetch', + ResT = unknown, + TError = unknown, + DefaultT = undefined, +>( + options: Omit, 'method'> & + Pick>, 'method'>, +) => RequestResult; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: FetchOptions['query']; + query?: FetchOptions['query']; + url: string; +} + +export type BuildUrlOptions< + TData extends Omit = Omit, +> = Pick, 'path' | 'query'> & + Pick & + Pick, 'baseURL' | 'querySerializer'>; + +type BuildUrlFn = >( + options: BuildUrlOptions, +) => string; + +export type Client = CoreClient; + +type OmitKeys = Pick>; + +export type Options< + TComposable extends Composable = '$fetch', + TData extends TDataShape = TDataShape, + ResT = unknown, + DefaultT = undefined, +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + WithRefs>; + +export type OptionsLegacyParser = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys & TData + : OmitKeys & + TData & + Pick + : TData extends { headers?: any } + ? OmitKeys & + TData & + Pick + : OmitKeys & TData; + +type FetchOptions = Omit< + UseFetchOptions, + keyof AsyncDataOptions +>; + +export type Composable = + | '$fetch' + | 'useAsyncData' + | 'useFetch' + | 'useLazyAsyncData' + | 'useLazyFetch'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/utils.gen.ts new file mode 100644 index 000000000..0a1d343e2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/client/utils.gen.ts @@ -0,0 +1,389 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ComputedRef, Ref } from 'vue'; +import { isRef, toValue, unref } from 'vue'; + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { + ArraySeparatorStyle, + BuildUrlOptions, + Client, + ClientOptions, + Config, + QuerySerializer, + RequestOptions, +} from './types.gen'; + +type PathSerializer = Pick, 'path' | 'url'>; + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type MaybeArray = T | T[]; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = toValue(toValue(path)[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + const qParams = toValue(queryParams); + if (qParams && typeof qParams === 'object') { + for (const name in qParams) { + const value = toValue(qParams[name]); + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + toValue(options.query)?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + toValue(options.query)[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseURL as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: Pick & { + baseUrl?: string; + querySerializer: QuerySerializer; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseURL?.endsWith('/')) { + config.baseURL = config.baseURL.substring(0, config.baseURL.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + let h: unknown = header; + if (isRef(h)) { + h = unref(h); + } + + const iterator = + h instanceof Headers + ? headersEntries(h) + : Object.entries(h as Record); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, unwrapRefs(v) as string); + } + } else if (value !== undefined) { + const v = unwrapRefs(value); + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof v === 'object' ? JSON.stringify(v) : (v as string), + ); + } + } + } + return mergedHeaders; +}; + +export const mergeInterceptors = (...args: Array>): Array => + args.reduce>((acc, item) => { + if (typeof item === 'function') { + acc.push(item); + } else if (Array.isArray(item)) { + return acc.concat(item); + } + return acc; + }, []); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); + +type UnwrapRefs = + T extends Ref + ? V + : T extends ComputedRef + ? V + : T extends Record // this doesn't handle functions well + ? { [K in keyof T]: UnwrapRefs } + : T; + +export const unwrapRefs = (value: T): UnwrapRefs => { + if (value === null || typeof value !== 'object' || value instanceof Headers) { + return (isRef(value) ? unref(value) : value) as UnwrapRefs; + } + + if (Array.isArray(value)) { + return value.map((item) => unwrapRefs(item)) as UnwrapRefs; + } + + if (isRef(value)) { + return unwrapRefs(unref(value) as T); + } + + // unwrap into new object to avoid modifying the source + const result: Record = {}; + for (const key in value) { + result[key] = unwrapRefs(value[key] as T); + } + return result as UnwrapRefs; +}; + +export const serializeBody = ( + opts: Pick[0], 'body' | 'bodySerializer'>, +) => { + if (opts.body && opts.bodySerializer) { + return opts.bodySerializer(opts.body); + } + return opts.body; +}; + +export const executeFetchFn = ( + opts: Omit[0], 'composable'>, + fetchFn: Required['$fetch'], +) => { + const unwrappedOpts = unwrapRefs(opts); + unwrappedOpts.rawBody = unwrappedOpts.body; + unwrappedOpts.body = serializeBody(unwrappedOpts); + return fetchFn( + buildUrl(opts), + // @ts-expect-error + unwrappedOpts, + ); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/auth.gen.ts new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/bodySerializer.gen.ts new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/params.gen.ts new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/pathSerializer.gen.ts new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/types.gen.ts new file mode 100644 index 000000000..9ef2b49db --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/types.gen.ts @@ -0,0 +1,123 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise; + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g. converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise; + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/utils.gen.ts new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdk.gen.ts new file mode 100644 index 000000000..c9c9a0d67 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdk.gen.ts @@ -0,0 +1,458 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, 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'; +import { exportRequestKeyMapper, patchApiVbyApiVersionNoTagRequestKeyMapper, importRequestKeyMapper, fooWowRequestKeyMapper, apiVVersionODataControllerCountRequestKeyMapper, getApiVbyApiVersionSimpleOperationRequestKeyMapper, deleteCallWithoutParametersAndResponseRequestKeyMapper, getCallWithoutParametersAndResponseRequestKeyMapper, headCallWithoutParametersAndResponseRequestKeyMapper, optionsCallWithoutParametersAndResponseRequestKeyMapper, patchCallWithoutParametersAndResponseRequestKeyMapper, postCallWithoutParametersAndResponseRequestKeyMapper, putCallWithoutParametersAndResponseRequestKeyMapper, deleteFooRequestKeyMapper, callWithDescriptionsRequestKeyMapper, deprecatedCallRequestKeyMapper, callWithParametersRequestKeyMapper, callWithWeirdParameterNamesRequestKeyMapper, getCallWithOptionalParamRequestKeyMapper, postCallWithOptionalParamRequestKeyMapper, postApiVbyApiVersionRequestBodyRequestKeyMapper, postApiVbyApiVersionFormDataRequestKeyMapper, callWithDefaultParametersRequestKeyMapper, callWithDefaultOptionalParametersRequestKeyMapper, callToTestOrderOfParamsRequestKeyMapper, duplicateNameRequestKeyMapper, duplicateName2RequestKeyMapper, duplicateName3RequestKeyMapper, duplicateName4RequestKeyMapper, callWithNoContentResponseRequestKeyMapper, callWithResponseAndNoContentResponseRequestKeyMapper, dummyARequestKeyMapper, dummyBRequestKeyMapper, callWithResponseRequestKeyMapper, callWithDuplicateResponsesRequestKeyMapper, callWithResponsesRequestKeyMapper, collectionFormatRequestKeyMapper, typesRequestKeyMapper, uploadFileRequestKeyMapper, fileResponseRequestKeyMapper, complexTypesRequestKeyMapper, multipartResponseRequestKeyMapper, multipartRequestRequestKeyMapper, complexParamsRequestKeyMapper, callWithResultFromHeaderRequestKeyMapper, testErrorCodeRequestKeyMapper, nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, putWithFormUrlEncodedRequestKeyMapper } from './sdkRequestMappers.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: exportRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchApiVbyApiVersionNoTagRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: importRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: fooWowRequestKeyMapper, + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: apiVVersionODataControllerCountRequestKeyMapper, + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getApiVbyApiVersionSimpleOperationRequestKeyMapper, + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).head({ + requestKeyMapper: headCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).options({ + requestKeyMapper: optionsCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).patch({ + requestKeyMapper: patchCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: putCallWithoutParametersAndResponseRequestKeyMapper, + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: deleteFooRequestKeyMapper, + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDescriptionsRequestKeyMapper, + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: deprecatedCallRequestKeyMapper, + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithParametersRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithWeirdParameterNamesRequestKeyMapper, + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: getCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postCallWithOptionalParamRequestKeyMapper, + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: postApiVbyApiVersionRequestBodyRequestKeyMapper, + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: postApiVbyApiVersionFormDataRequestKeyMapper, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const callWithDefaultParameters = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithDefaultParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDefaultOptionalParametersRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callToTestOrderOfParamsRequestKeyMapper, + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options: Options) => { + return (options.client ?? client).delete({ + requestKeyMapper: duplicateNameRequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: duplicateName2RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: duplicateName3RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: duplicateName4RequestKeyMapper, + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseAndNoContentResponseRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyARequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: dummyBRequestKeyMapper, + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: callWithResponseRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithDuplicateResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: callWithResponsesRequestKeyMapper, + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: collectionFormatRequestKeyMapper, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: typesRequestKeyMapper, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: uploadFileRequestKeyMapper, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: fileResponseRequestKeyMapper, + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: complexTypesRequestKeyMapper, + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options: Options) => { + return (options.client ?? client).get({ + requestKeyMapper: multipartResponseRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options: Options) => { + return (options.client ?? client).post({ + ...formDataBodySerializer, + requestKeyMapper: multipartRequestRequestKeyMapper, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + requestKeyMapper: complexParamsRequestKeyMapper, + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: callWithResultFromHeaderRequestKeyMapper, + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: testErrorCodeRequestKeyMapper, + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + requestKeyMapper: nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + requestKeyMapper: putWithFormUrlEncodedRequestKeyMapper, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts new file mode 100644 index 000000000..ffd6dba4b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/sdkRequestMappers.gen.ts @@ -0,0 +1,1491 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export function exportRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchApiVbyApiVersionNoTagRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function importRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function fooWowRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function apiVVersionODataControllerCountRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getApiVbyApiVersionSimpleOperationRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + } +} + +export function deleteCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function getCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function headCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function optionsCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function patchCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function putCallWithoutParametersAndResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deleteFooRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["xFooBar"] !== "undefined") { + const _seedSetRet = options.headers.set("xFooBar", options.Headers["xFooBar"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["xFooBar"]; + } + } + const _val = options.headers.get("xFooBar"); + if (_val !== null) { + const _setRet = options.headers.set("x-Foo-Bar", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("xFooBar"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('fooParam' in options.path) { + options.path.foo_param = options.path.fooParam; + delete options.path.fooParam; + } + if ('barParam' in options.path) { + options.path.BarParam = options.path.barParam; + delete options.path.barParam; + } + } +} + +export function callWithDescriptionsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function deprecatedCallRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('fooRefEnum' in options.query) { + options.query.foo_ref_enum = options.query.fooRefEnum; + delete options.query.fooRefEnum; + } + if ('fooAllOfEnum' in options.query) { + options.query.foo_all_of_enum = options.query.fooAllOfEnum; + delete options.query.fooAllOfEnum; + } + } +} + +export function callWithWeirdParameterNamesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if ("Headers" in options) { + if (typeof options.Headers["parameterHeader"] !== "undefined") { + const _seedSetRet = options.headers.set("parameterHeader", options.Headers["parameterHeader"] as any); + if (typeof _seedSetRet !== "undefined") { + options.headers = _seedSetRet as any; + } + delete options.Headers["parameterHeader"]; + } + } + const _val = options.headers.get("parameterHeader"); + if (_val !== null) { + const _setRet = options.headers.set("parameter.header", _val as any); + if (typeof _setRet !== "undefined") { + options.headers = _setRet as any; + } + if ("delete" in options.headers) { + const _delRet = options.headers.delete("parameterHeader"); + if (typeof _delRet !== "undefined") { + options.headers = _delRet as any; + } + } + } + if (options.path) { + if ('parameterPath1' in options.path) { + options.path['parameter.path.1'] = options.path.parameterPath1; + delete options.path.parameterPath1; + } + if ('parameterPath2' in options.path) { + options.path['parameter-path-2'] = options.path.parameterPath2; + delete options.path.parameterPath2; + } + if ('parameterPath3' in options.path) { + options.path['PARAMETER-PATH-3'] = options.path.parameterPath3; + delete options.path.parameterPath3; + } + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.query) { + if ('parameterQuery' in options.query) { + options.query['parameter-query'] = options.query.parameterQuery; + delete options.query.parameterQuery; + } + } +} + +export function getCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postCallWithOptionalParamRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionRequestBodyRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function postApiVbyApiVersionFormDataRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDefaultOptionalParametersRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callToTestOrderOfParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateNameRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName2RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName3RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function duplicateName4RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseAndNoContentResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyARequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function dummyBRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithDuplicateResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function callWithResponsesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function collectionFormatRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('parameterArrayCsv' in options.query) { + options.query.parameterArrayCSV = options.query.parameterArrayCsv; + delete options.query.parameterArrayCsv; + } + if ('parameterArraySsv' in options.query) { + options.query.parameterArraySSV = options.query.parameterArraySsv; + delete options.query.parameterArraySsv; + } + if ('parameterArrayTsv' in options.query) { + options.query.parameterArrayTSV = options.query.parameterArrayTsv; + delete options.query.parameterArrayTsv; + } + } +} + +export function typesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function uploadFileRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function fileResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } +} + +export function complexTypesRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartResponseRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function multipartRequestRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function complexParamsRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.path) { + if ('apiVersion' in options.path) { + options.path['api-version'] = options.path.apiVersion; + delete options.path.apiVersion; + } + } + if (options.body) { + if ('parameters' in options.body && (typeof options.body.parameters === "object" && options.body.parameters !== null)) + if ('foo_bar-enum' in options.body.parameters) + if ('fooBarEnum' in options.body.parameters['foo_bar-enum']) { + options.body.parameters['foo_bar-enum']['foo_bar-enum'] = options.body.parameters['foo_bar-enum'].fooBarEnum; + delete options.body.parameters['foo_bar-enum'].fooBarEnum; + } + } +} + +export function callWithResultFromHeaderRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function testErrorCodeRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} + +export function nonAsciiæøåÆøÅöôêÊ字符串RequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } + if (options.query) { + if ('nonAsciiParamæøåÆøÅöôêÊ' in options.query) { + options.query.nonAsciiParamæøåÆØÅöôêÊ = options.query.nonAsciiParamæøåÆøÅöôêÊ; + delete options.query.nonAsciiParamæøåÆøÅöôêÊ; + } + } +} + +export function putWithFormUrlEncodedRequestKeyMapper(options: any) { + if ("Path" in options) { + if (!("path" in options)) + options.path = options.Path as any; + delete options.Path; + } + if ("Query" in options) { + if (!("query" in options)) + options.query = options.Query as any; + delete options.Query; + } + if ("Headers" in options) { + if (!("headers" in options)) + options.headers = options.Headers as any; + delete options.Headers; + } + if ("Url" in options) { + if (!("url" in options)) + options.url = options.Url as any; + delete options.Url; + } + if ("Body" in options) { + if (!("body" in options)) + options.body = options.Body as any; + delete options.Body; + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/types.gen.ts new file mode 100644 index 000000000..bc7cc8f46 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-preserve-wire-casing/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16X16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + fooBarBazQux?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + fooBarEnum?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updatedAt?: string; + /** + * Created at + */ + readonly createdAt?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + string?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + arrayStrings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

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

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + object?: { + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }; + array?: Array<{ + description?: string; + xEnumDescriptions?: string; + xEnumVarnames?: string; + xEnumNames?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + propertyWithSpace?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + fooParam: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + xFooBar: ModelWithString; + }; + path: { + /** + * foo in method + */ + fooParam: string; + /** + * bar in method + */ + barParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath1?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath2?: string; + /** + * This is the parameter that goes into the path + */ + parameterPath3?: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + parameterQuery: string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4Xx': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespaceString'?: string; + readonly '@namespaceInteger'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCsv: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySsv: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTsv: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + apiVersion: string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + apiVersion: string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆøÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.gen.ts index 5bb268ce4..d9c8e5374 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts index cc8a9e60f..c703e9ed4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts index 1555ca230..01e8d2e64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts @@ -122,6 +122,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client/client.gen.ts index c8a60c6fa..bf13f1c8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 53d0433b9..2e86bede8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -60,6 +60,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/client.gen.ts index 3dbbcd126..f9fd67a26 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/client.gen.ts @@ -54,6 +54,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index a439d2748..b6d0dff2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -61,6 +61,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/core/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/core/types.gen.ts.snap index 643c070c9..9ef2b49db 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/core/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/core/types.gen.ts.snap @@ -84,6 +84,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts-tests/main/test/clients.test.ts b/packages/openapi-ts-tests/main/test/clients.test.ts index af3a0b1b6..896381ef9 100644 --- a/packages/openapi-ts-tests/main/test/clients.test.ts +++ b/packages/openapi-ts-tests/main/test/clients.test.ts @@ -136,6 +136,61 @@ for (const client of clients) { }), description: 'client with strict base URL', }, + { + config: createConfig({ + output: { + case: 'camelCase', + path: 'sdk-preserve-wire-casing', + }, + plugins: [ + client, + { + name: '@hey-api/sdk', + preserveWireCasing: true, + }, + ], + }), + description: 'SDK with preserve wire casing', + }, + { + config: createConfig({ + input: path.join( + getSpecsPath(), + '3.1.x', + 'preserve-wire-casing-extreme-test.json', + ), + output: { + case: 'camelCase', + path: 'sdk-preserve-wire-casing-extreme', + }, + plugins: [ + client, + { + name: '@hey-api/sdk', + preserveWireCasing: true, + }, + ], + }), + description: 'SDK with preserve wire casing extreme', + }, + { + config: createConfig({ + output: { + case: 'camelCase', + path: 'sdk-preserve-wire-casing-zod', + }, + plugins: [ + client, + 'zod', + { + name: '@hey-api/sdk', + preserveWireCasing: true, + validator: true, + }, + ], + }), + description: 'SDK with preserve wire casing and zod validator', + }, { config: createConfig({ output: { diff --git a/packages/openapi-ts-tests/specs/3.1.x/preserve-wire-casing-extreme-test.json b/packages/openapi-ts-tests/specs/3.1.x/preserve-wire-casing-extreme-test.json new file mode 100644 index 000000000..ae870d98a --- /dev/null +++ b/packages/openapi-ts-tests/specs/3.1.x/preserve-wire-casing-extreme-test.json @@ -0,0 +1,717 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Extreme Wire Casing Test API", + "version": "1.0.0", + "description": "Comprehensive test for all possible wire casing transformation scenarios" + }, + "servers": [ + { + "url": "https://api.example.com" + } + ], + "components": { + "schemas": { + "Level5DeepObject": { + "type": "object", + "properties": { + "final_value": { "type": "string" } + } + }, + "Level4DeepObject": { + "type": "object", + "properties": { + "deep_prop": { "$ref": "#/components/schemas/Level5DeepObject" } + } + }, + "Level3DeepObject": { + "type": "object", + "properties": { + "another_level": { "$ref": "#/components/schemas/Level4DeepObject" } + } + }, + "NestedArrayItem": { + "type": "object", + "properties": { + "item_name": { "type": "string" }, + "item_metadata": { + "type": "object", + "properties": { + "creation_date": { "type": "string" }, + "nested_config": { + "type": "object", + "properties": { + "is_enabled": { "type": "boolean" }, + "priority_level": { "type": "integer" } + } + } + } + }, + "sub_items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "sub_name": { "type": "string" }, + "sub_details": { + "type": "object", + "properties": { + "category_type": { "type": "string" }, + "status_info": { + "type": "object", + "properties": { + "is_active": { "type": "boolean" }, + "last_update": { "type": "string" } + } + } + } + } + } + } + } + } + }, + "ComplexAdditionalPropsValue": { + "type": "object", + "properties": { + "prop_name": { "type": "string" }, + "prop_settings": { + "type": "object", + "properties": { + "config_value": { "type": "string" }, + "nested_rules": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "rule_type": { "type": "string" }, + "rule_parameters": { + "type": "object", + "properties": { + "param_name": { "type": "string" }, + "param_value": { "type": "any" } + } + } + } + } + } + } + } + } + }, + "MatrixCell": { + "type": "object", + "properties": { + "cell_value": { "type": "number" }, + "cell_metadata": { + "type": "object", + "properties": { + "data_type": { "type": "string" }, + "validation_rules": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rule_name": { "type": "string" }, + "rule_config": { + "type": "object", + "properties": { + "min_value": { "type": "number" }, + "max_value": { "type": "number" } + } + } + } + } + } + } + } + } + }, + "ExtremeTestRequestBody": { + "type": "object", + "properties": { + "simple_prop": { "type": "string" }, + "level_two": { + "type": "object", + "properties": { + "level_three": { "$ref": "#/components/schemas/Level3DeepObject" } + } + }, + "six_level_deep": { + "type": "object", + "properties": { + "level_one": { + "type": "object", + "properties": { + "level_two": { + "type": "object", + "properties": { + "level_three": { + "type": "object", + "properties": { + "level_four": { + "type": "object", + "properties": { + "level_five": { + "type": "object", + "properties": { + "final_deep_value": { "type": "string" } + } + } + } + } + } + } + } + } + } + } + } + }, + "simple_array": { + "type": "array", + "items": { "$ref": "#/components/schemas/NestedArrayItem" } + }, + "array_with_deep_nesting": { + "type": "array", + "items": { + "type": "object", + "properties": { + "item_id": { "type": "string" }, + "deep_nested": { + "type": "object", + "properties": { + "level_one": { + "type": "object", + "properties": { + "level_two": { + "type": "object", + "properties": { + "final_array_value": { "type": "string" } + } + } + } + } + } + }, + "sub_arrays": { + "type": "array", + "items": { + "type": "object", + "properties": { + "sub_id": { "type": "string" }, + "sub_data": { + "type": "object", + "properties": { + "data_value": { "type": "string" }, + "data_config": { + "type": "object", + "properties": { + "config_name": { "type": "string" } + } + } + } + } + } + } + } + } + } + }, + "matrix_data": { + "type": "array", + "items": { + "type": "array", + "items": { "$ref": "#/components/schemas/MatrixCell" } + } + }, + "three_level_array": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "deep_array_value": { "type": "string" }, + "deep_array_config": { + "type": "object", + "properties": { + "setting_name": { "type": "string" } + } + } + } + } + } + } + }, + "simple_additional_props": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/ComplexAdditionalPropsValue" + } + }, + "additional_props_with_deep_nesting": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "dynamic_prop": { "type": "string" }, + "dynamic_nested": { + "type": "object", + "properties": { + "nested_level_one": { + "type": "object", + "properties": { + "nested_level_two": { + "type": "object", + "properties": { + "final_dynamic_value": { "type": "string" } + } + } + } + } + } + }, + "dynamic_arrays": { + "type": "array", + "items": { + "type": "object", + "properties": { + "array_item_prop": { "type": "string" }, + "array_item_nested": { + "type": "object", + "properties": { + "nested_array_value": { "type": "string" } + } + } + } + } + } + } + } + }, + "mixed_additional_props_arrays": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "mixed_prop": { "type": "string" }, + "mixed_deep": { + "type": "object", + "properties": { + "deep_mixed_value": { "type": "string" } + } + } + } + } + } + } + }, + "pattern_properties_test": { + "type": "object", + "patternProperties": { + "^config_.*": { + "type": "object", + "properties": { + "pattern_value": { "type": "string" }, + "pattern_nested": { + "type": "object", + "properties": { + "nested_pattern_value": { "type": "string" } + } + } + } + } + } + }, + "composition_test": { + "allOf": [ + { + "type": "object", + "properties": { + "base_prop": { "type": "string" } + } + }, + { + "type": "object", + "properties": { + "extended_prop": { "type": "string" }, + "extended_nested": { + "type": "object", + "properties": { + "composition_deep_value": { "type": "string" } + } + } + } + } + ] + }, + "one_of_test": { + "oneOf": [ + { + "type": "object", + "properties": { + "option_a_prop": { "type": "string" }, + "option_a_nested": { + "type": "object", + "properties": { + "option_a_deep": { "type": "string" } + } + } + } + }, + { + "type": "object", + "properties": { + "option_b_prop": { "type": "string" }, + "option_b_array": { + "type": "array", + "items": { + "type": "object", + "properties": { + "option_b_item": { "type": "string" } + } + } + } + } + } + ] + } + } + }, + "ComplexQueryParams": { + "type": "object", + "properties": { + "simple_filter": { "type": "string" }, + "nested_filter": { + "type": "object", + "properties": { + "date_range": { + "type": "object", + "properties": { + "start_date": { "type": "string" }, + "end_date": { "type": "string" }, + "time_zone": { + "type": "object", + "properties": { + "zone_name": { "type": "string" }, + "zone_offset": { "type": "integer" } + } + } + } + }, + "categories": { + "type": "array", + "items": { + "type": "object", + "properties": { + "category_id": { "type": "string" }, + "category_settings": { + "type": "object", + "properties": { + "include_subcategories": { "type": "boolean" }, + "priority_level": { "type": "integer" } + } + } + } + } + } + } + }, + "dynamic_filters": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "filter_value": { "type": "string" }, + "filter_options": { + "type": "object", + "properties": { + "case_sensitive": { "type": "boolean" }, + "match_type": { "type": "string" } + } + } + } + } + } + } + } + } + }, + "paths": { + "/extreme-test": { + "post": { + "summary": "Extreme test endpoint for all wire casing scenarios", + "description": "Tests every possible combination of nesting, arrays, additionalProperties, and composition schemas", + "parameters": [ + { + "name": "SimpleParam", + "in": "query", + "schema": { "type": "string" } + }, + { + "name": "ComplexQuery", + "in": "query", + "style": "deepObject", + "explode": true, + "schema": { "$ref": "#/components/schemas/ComplexQueryParams" } + }, + { + "name": "PathParam", + "in": "path", + "required": true, + "schema": { "type": "string" } + }, + { + "name": "XRequestId", + "in": "header", + "schema": { "type": "string" } + }, + { + "name": "SessionToken", + "in": "cookie", + "schema": { "type": "string" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExtremeTestRequestBody" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" } + } + } + } + } + } + } + } + }, + "/matrix-test/{MatrixId}": { + "put": { + "summary": "Test multi-dimensional arrays with deep nesting", + "parameters": [ + { + "name": "MatrixId", + "in": "path", + "required": true, + "schema": { "type": "string" } + }, + { + "name": "XTraceId", + "in": "header", + "schema": { "type": "string" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "matrix_name": { "type": "string" }, + "matrix_data": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "cell_value": { "type": "number" }, + "cell_metadata": { + "type": "object", + "properties": { + "row_index": { "type": "integer" }, + "col_index": { "type": "integer" }, + "layer_index": { "type": "integer" }, + "validation_info": { + "type": "object", + "properties": { + "is_valid": { "type": "boolean" }, + "error_messages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "error_code": { "type": "string" }, + "error_details": { + "type": "object", + "properties": { + "message_text": { + "type": "string" + }, + "severity_level": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/dynamic-config": { + "patch": { + "summary": "Test complex additionalProperties with nested arrays", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "config_name": { "type": "string" }, + "dynamic_settings": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "setting_value": { "type": "string" }, + "setting_metadata": { + "type": "object", + "properties": { + "created_by": { "type": "string" }, + "created_at": { "type": "string" }, + "nested_config": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "nested_value": { "type": "string" }, + "nested_arrays": { + "type": "array", + "items": { + "type": "object", + "properties": { + "array_item_id": { "type": "string" }, + "array_item_data": { + "type": "object", + "properties": { + "data_type": { "type": "string" }, + "data_value": { "type": "any" } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "rule_sets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rule_set_name": { "type": "string" }, + "rule_definitions": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rule_type": { "type": "string" }, + "rule_parameters": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "param_name": { "type": "string" }, + "param_config": { + "type": "object", + "properties": { + "config_value": { "type": "any" }, + "config_validation": { + "type": "object", + "properties": { + "validation_type": { + "type": "string" + }, + "validation_rules": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rule_name": { + "type": "string" + }, + "rule_expression": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + } + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index fd34020b6..077e6f624 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -120,6 +120,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts as any); + } + return { opts, req, url }; }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/client.ts index fb7e69a3a..a38ced60c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/client.ts @@ -58,6 +58,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.body = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts index 4afdb3589..35f4ba465 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/types.ts @@ -82,6 +82,11 @@ export interface Config { * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * Remap request option keys from SDK-facing casing to wire/spec casing. + * Applied after request validation and before URL build/body serialization. + */ + requestKeyMapper?: (options: any) => void; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/requestKeyMapper.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/requestKeyMapper.test.ts new file mode 100644 index 000000000..93703a9fc --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/requestKeyMapper.test.ts @@ -0,0 +1,390 @@ +import { describe, expect, it } from 'vitest'; + +import { createClient } from '../bundle'; + +describe('requestKeyMapper (fetch client)', () => { + it('remaps path and query keys before URL build', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + await client.get({ + path: { fooBar: 123 }, + query: { barBaz: 'x' }, + requestKeyMapper: (opts: any) => { + if (opts.path && 'fooBar' in opts.path) { + opts.path.foo_bar = opts.path.fooBar; + delete opts.path.fooBar; + } + if (opts.query && 'barBaz' in opts.query) { + opts.query.bar_baz = opts.query.barBaz; + delete opts.query.barBaz; + } + }, + url: '/r/{foo_bar}', + }); + + expect(capturedRequest).toBeTruthy(); + expect(capturedRequest!.url).toMatch(/\/r\/123\?bar_baz=x$/); + }); + + it('remaps header and body keys before serialization', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + + await client.post({ + body: { fooBar: 'baz' }, + headers: { XFizzBuzz: 'ok' }, + requestKeyMapper: (opts: any) => { + if (opts.headers && opts.headers.get('XFizzBuzz') !== undefined) { + opts.headers.set('X-Fizz-Buzz', opts.headers.get('XFizzBuzz')); + opts.headers.delete('XFizzBuzz'); + } + if (opts.body && 'fooBar' in opts.body) { + opts.body.foo_bar = opts.body.fooBar; + delete opts.body.fooBar; + } + }, + url: '/r', + }); + + expect(capturedRequest).toBeTruthy(); + // headers + expect(capturedRequest!.headers.get('X-Fizz-Buzz')).toBe('ok'); + // body + const body = await capturedRequest!.clone().text(); + expect(body).toBe('{"foo_bar":"baz"}'); + }); + + it('remaps deep nested object properties', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { 'Content-Type': 'application/json' }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + + await client.post({ + body: { + user: { + personalInfo: { + contactDetails: { + emailAddress: 'john@example.com', + }, + firstName: 'John', + lastName: 'Doe', + }, + }, + }, + requestKeyMapper: (opts: any) => { + // Deep nesting: user.personalInfo.firstName → user.personal_info.first_name + if (opts.body?.user?.personalInfo) { + // Level 1: personalInfo → personal_info + opts.body.user.personal_info = opts.body.user.personalInfo; + delete opts.body.user.personalInfo; + + const info = opts.body.user.personal_info; + // Level 2: firstName → first_name + if ('firstName' in info) { + info.first_name = info.firstName; + delete info.firstName; + } + // Level 2: lastName → last_name + if ('lastName' in info) { + info.last_name = info.lastName; + delete info.lastName; + } + // Level 3: contactDetails.emailAddress → contact_details.email_address + if (info.contactDetails) { + info.contact_details = info.contactDetails; + delete info.contactDetails; + if ('emailAddress' in info.contact_details) { + info.contact_details.email_address = + info.contact_details.emailAddress; + delete info.contact_details.emailAddress; + } + } + } + }, + url: '/users', + }); + + expect(capturedRequest).toBeTruthy(); + const body = await capturedRequest!.clone().text(); + const parsed = JSON.parse(body); + + expect(parsed).toEqual({ + user: { + personal_info: { + contact_details: { + email_address: 'john@example.com', + }, + first_name: 'John', + last_name: 'Doe', + }, + }, + }); + }); + + it('remaps array items with nested properties', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { 'Content-Type': 'application/json' }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + + await client.post({ + body: { + users: [ + { + roles: [ + { permissions: { canEdit: true }, roleName: 'admin' }, + { permissions: { canRead: true }, roleName: 'user' }, + ], + userInfo: { firstName: 'John', isActive: true }, + }, + { + roles: [{ permissions: { canRead: true }, roleName: 'user' }], + userInfo: { firstName: 'Jane', isActive: false }, + }, + ], + }, + requestKeyMapper: (opts: any) => { + if (opts.body?.users && Array.isArray(opts.body.users)) { + for (const user of opts.body.users) { + // Remap userInfo → user_info + if (user.userInfo) { + user.user_info = user.userInfo; + delete user.userInfo; + + // Remap firstName → first_name, isActive → is_active + if ('firstName' in user.user_info) { + user.user_info.first_name = user.user_info.firstName; + delete user.user_info.firstName; + } + if ('isActive' in user.user_info) { + user.user_info.is_active = user.user_info.isActive; + delete user.user_info.isActive; + } + } + + // Remap roles array items + if (user.roles && Array.isArray(user.roles)) { + for (const role of user.roles) { + // roleName → role_name + if ('roleName' in role) { + role.role_name = role.roleName; + delete role.roleName; + } + // permissions.canEdit → permissions.can_edit + if (role.permissions) { + if ('canEdit' in role.permissions) { + role.permissions.can_edit = role.permissions.canEdit; + delete role.permissions.canEdit; + } + if ('canRead' in role.permissions) { + role.permissions.can_read = role.permissions.canRead; + delete role.permissions.canRead; + } + } + } + } + } + } + }, + url: '/users', + }); + + expect(capturedRequest).toBeTruthy(); + const body = await capturedRequest!.clone().text(); + const parsed = JSON.parse(body); + + expect(parsed).toEqual({ + users: [ + { + roles: [ + { permissions: { can_edit: true }, role_name: 'admin' }, + { permissions: { can_read: true }, role_name: 'user' }, + ], + user_info: { first_name: 'John', is_active: true }, + }, + { + roles: [{ permissions: { can_read: true }, role_name: 'user' }], + user_info: { first_name: 'Jane', is_active: false }, + }, + ], + }); + }); + + it('remaps additionalProperties with Object.keys iteration', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { 'Content-Type': 'application/json' }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + + await client.post({ + body: { + metadata: { + config_one: { isEnabled: true, settingValue: 'value1' }, + config_three: { isEnabled: true, settingValue: 'value3' }, + config_two: { isEnabled: false, settingValue: 'value2' }, + }, + }, + requestKeyMapper: (opts: any) => { + if (opts.body?.metadata && typeof opts.body.metadata === 'object') { + // Iterate over dynamic properties + for (const key of Object.keys(opts.body.metadata)) { + const config = opts.body.metadata[key]; + if (config && typeof config === 'object') { + // settingValue → setting_value + if ('settingValue' in config) { + config.setting_value = config.settingValue; + delete config.settingValue; + } + // isEnabled → is_enabled + if ('isEnabled' in config) { + config.is_enabled = config.isEnabled; + delete config.isEnabled; + } + } + } + } + }, + url: '/configs', + }); + + expect(capturedRequest).toBeTruthy(); + const body = await capturedRequest!.clone().text(); + const parsed = JSON.parse(body); + + expect(parsed).toEqual({ + metadata: { + config_one: { is_enabled: true, setting_value: 'value1' }, + config_three: { is_enabled: true, setting_value: 'value3' }, + config_two: { is_enabled: false, setting_value: 'value2' }, + }, + }); + }); + + it('remaps multi-dimensional arrays', async () => { + let capturedRequest: Request | undefined; + const mockFetch = async (request: Request) => { + capturedRequest = request; + return new Response('{}', { + headers: { 'Content-Type': 'application/json' }, + status: 200, + }); + }; + + const client = createClient({ + baseUrl: 'https://api.test', + fetch: mockFetch as any, + }); + + await client.post({ + body: { + matrix: [ + [ + { cellMeta: { dataType: 'number' }, cellValue: 1 }, + { cellMeta: { dataType: 'number' }, cellValue: 2 }, + ], + [ + { cellMeta: { dataType: 'number' }, cellValue: 3 }, + { cellMeta: { dataType: 'number' }, cellValue: 4 }, + ], + ], + }, + requestKeyMapper: (opts: any) => { + if (opts.body?.matrix && Array.isArray(opts.body.matrix)) { + for (const row of opts.body.matrix) { + if (Array.isArray(row)) { + for (const cell of row) { + // cellValue → cell_value + if ('cellValue' in cell) { + cell.cell_value = cell.cellValue; + delete cell.cellValue; + } + // cellMeta → cell_meta + if (cell.cellMeta) { + cell.cell_meta = cell.cellMeta; + delete cell.cellMeta; + // dataType → data_type + if ('dataType' in cell.cell_meta) { + cell.cell_meta.data_type = cell.cell_meta.dataType; + delete cell.cell_meta.dataType; + } + } + } + } + } + } + }, + url: '/matrix', + }); + + expect(capturedRequest).toBeTruthy(); + const body = await capturedRequest!.clone().text(); + const parsed = JSON.parse(body); + + expect(parsed).toEqual({ + matrix: [ + [ + { cell_meta: { data_type: 'number' }, cell_value: 1 }, + { cell_meta: { data_type: 'number' }, cell_value: 2 }, + ], + [ + { cell_meta: { data_type: 'number' }, cell_value: 3 }, + { cell_meta: { data_type: 'number' }, cell_value: 4 }, + ], + ], + }); + }); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index b4932899a..0a9c586ff 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -59,6 +59,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index e3fb833f8..42457473d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -58,6 +58,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts index 432ffbd40..2cc4232e6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts @@ -52,6 +52,10 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + if (opts.requestKeyMapper) { + opts.requestKeyMapper(opts); + } + const url = buildUrl(opts); return { opts, url }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts index 9396cb2c0..96401c82d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts @@ -18,6 +18,7 @@ export const defaultConfig: HeyApiSdkPlugin['Config'] = { instance: false, operationId: true, params_EXPERIMENTAL: 'default', + preserveWireCasing: false, response: 'body', responseStyle: 'fields', transformer: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts index d4a2eb5a8..89d5854d6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts @@ -16,6 +16,7 @@ import { getClientPlugin } from '../client-core/utils'; import type { PluginState } from '../typescript/types'; import { operationAuth } from './auth'; import { nuxtTypeComposable, nuxtTypeDefault } from './constants'; +import { createRequestKeyMapper } from './requestKeyMapper'; import type { HeyApiSdkPlugin } from './types'; import { createRequestValidator, createResponseValidator } from './validator'; @@ -492,6 +493,20 @@ export const operationStatements = ({ } } + const requestKeyMapperInfo = createRequestKeyMapper({ operation, plugin }); + if (requestKeyMapperInfo) { + // Add import for the shared mapper function + f.addImport({ + from: requestKeyMapperInfo.file, + names: [requestKeyMapperInfo.placeholder], + }); + + requestOptions.push({ + key: 'requestKeyMapper', + value: requestKeyMapperInfo.placeholder, + }); + } + // TODO: parser - set parseAs to skip inference if every response has the same // content type. currently impossible because successes do not contain // header information @@ -780,7 +795,7 @@ export const operationStatements = ({ tsc.returnFunctionCall({ args: [ tsc.objectExpression({ - identifiers: ['responseTransformer'], + identifiers: ['requestKeyMapper', 'responseTransformer'], obj: requestOptions, }), ], diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/requestKeyMapper.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/requestKeyMapper.ts new file mode 100644 index 000000000..f7615cdee --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/requestKeyMapper.ts @@ -0,0 +1,1227 @@ +import type { ICodegenFile } from '@hey-api/codegen-core'; +import ts from 'typescript'; + +import { TypeScriptRenderer } from '../../../generate/renderer'; +import type { IR } from '../../../ir/types'; +import { tsc } from '../../../tsc'; +import { stringCase } from '../../../utils/stringCase'; +import type { HeyApiSdkPlugin } from './types'; + +export interface PropertyMapping { + from: string; + path: string; + to: string; +} + +/** + * Prefix mapping paths with a given path prefix, if provided. + */ +const prefixMappings = ( + base: ReadonlyArray, + pathPrefix: string, +): Array => { + if (!pathPrefix) { + return [...base]; + } + + return base.map((item) => ({ + ...item, + path: `${pathPrefix}.${item.path}`, + })); +}; + +/** + * Remove duplicate mapping entries. + */ +const dedupeMappings = ( + mappings: ReadonlyArray, +): Array => { + const seen = new Set(); + const result: Array = []; + + for (const mapping of mappings) { + const key = `${mapping.from}::${mapping.path}::${mapping.to}`; + if (!seen.has(key)) { + seen.add(key); + result.push(mapping); + } + } + + return result; +}; + +/** + * Recursively traverses a schema to collect all property mappings for wire casing preservation. + * Handles nested objects, arrays, composition schemas (logicalOperator + items), and references. + */ +export const collectSchemaPropertyMappings = (options: { + cache?: Map>; + context: IR.Context; + outputCase: Parameters[0]['case']; + pathPrefix?: string; + schema: IR.SchemaObject; + visited?: Set; +}): Array => { + const { + cache, + context, + outputCase, + pathPrefix = '', + schema, + visited = new Set(), + } = options; + const mappings: Array = []; + + // Handle $ref schemas + if (schema.$ref) { + // Prevent circular references - if we've already visited this ref, skip it + if (visited.has(schema.$ref)) { + return mappings; + } + visited.add(schema.$ref); + + // Serve from cache if available + if (cache?.has(schema.$ref)) { + const base = cache.get(schema.$ref)!; + const resolved = prefixMappings(base, pathPrefix); + mappings.push(...resolved); + visited.delete(schema.$ref); + return mappings; + } + + // First try resolving against IR. IR refs can point to either a schema + // directly or an object that contains a `schema` (e.g., requestBodies). + try { + const irResolved = context.resolveIrRef( + schema.$ref, + ) as unknown as Record; + + const candidateSchema: IR.SchemaObject | undefined = + (irResolved && 'schema' in irResolved + ? (irResolved.schema as IR.SchemaObject) + : (irResolved as unknown as IR.SchemaObject)) || undefined; + + if (candidateSchema) { + // Collect base mappings without a prefix for cache correctness + const baseMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: '', + schema: candidateSchema, + visited, + }); + cache?.set(schema.$ref, baseMappings); + const resolved = prefixMappings(baseMappings, pathPrefix); + mappings.push(...resolved); + visited.delete(schema.$ref); + return mappings; + } + } catch { + // ignore and try spec resolution + } + + // Fallback to resolving against the original spec (for non-IR pointers) + try { + const specResolved = context.resolveRef( + schema.$ref, + ) as unknown as Record; + + // If the ref points to a RequestBodyObject in the spec + if (specResolved && 'content' in specResolved) { + const content = specResolved.content as + | Record + | undefined; + let jsonSchema: unknown | undefined; + + if (content) { + // Prefer application/json, otherwise pick the first entry + jsonSchema = content['application/json']?.schema; + if (!jsonSchema) { + const first = Object.values(content)[0]; + jsonSchema = first?.schema; + } + } + + if (jsonSchema) { + const baseMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: '', + // Cast is safe for traversal as we only access JSON Schema-like fields + schema: jsonSchema as unknown as IR.SchemaObject, + visited, + }); + cache?.set(schema.$ref, baseMappings); + const resolved = prefixMappings(baseMappings, pathPrefix); + mappings.push(...resolved); + visited.delete(schema.$ref); + return mappings; + } + } + + // If the ref points directly to a SchemaObject in the spec + if ( + specResolved && + ('type' in specResolved || 'properties' in specResolved) + ) { + const baseMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: '', + schema: specResolved as unknown as IR.SchemaObject, + visited, + }); + cache?.set(schema.$ref, baseMappings); + const resolved = prefixMappings(baseMappings, pathPrefix); + mappings.push(...resolved); + visited.delete(schema.$ref); + return mappings; + } + } catch { + // If both resolution methods fail, skip this $ref + } + + visited.delete(schema.$ref); + return mappings; + } + + // Handle object properties + if (schema.type === 'object' && schema.properties) { + for (const propertyName in schema.properties) { + const property = schema.properties[propertyName]!; + const wire = propertyName; + const generated = stringCase({ case: outputCase, value: wire }); + const currentPath = pathPrefix + ? `${pathPrefix}.${propertyName}` + : propertyName; + + // Add mapping if property name changes + if (generated !== wire) { + mappings.push({ from: generated, path: currentPath, to: wire }); + } + + // Recursively handle nested schemas + const nestedMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: currentPath, + schema: property, + visited, + }); + mappings.push(...nestedMappings); + } + } + + // Handle additionalProperties + if ( + schema.additionalProperties && + typeof schema.additionalProperties === 'object' + ) { + const additionalMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: pathPrefix ? `${pathPrefix}[*]` : `[*]`, + schema: schema.additionalProperties, + visited, + }); + mappings.push(...additionalMappings); + } + + // Handle patternProperties + if (schema.patternProperties) { + for (const pattern in schema.patternProperties) { + const patternSchema = schema.patternProperties[pattern]!; + const patternMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: pathPrefix ? `${pathPrefix}.[${pattern}]` : `[${pattern}]`, + schema: patternSchema, + visited, + }); + mappings.push(...patternMappings); + } + } + + // Handle array items + if (schema.type === 'array' && schema.items) { + // Handle both single item schema and array of schemas + const itemSchemas = Array.isArray(schema.items) + ? schema.items + : [schema.items]; + + for (let i = 0; i < itemSchemas.length; i++) { + const itemSchema = itemSchemas[i]!; + const itemMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix: pathPrefix ? `${pathPrefix}[*]` : `[*]`, + schema: itemSchema, + visited, + }); + mappings.push(...itemMappings); + } + } + + // Handle composition schemas via items array + // In the IR, composition schemas (allOf, oneOf, anyOf) are flattened into the items array + if (schema.items && schema.logicalOperator) { + for (let i = 0; i < schema.items.length; i++) { + const compositionSchema = schema.items[i]!; + const compositionMappings = collectSchemaPropertyMappings({ + cache, + context, + outputCase, + pathPrefix, + schema: compositionSchema, + visited, + }); + mappings.push(...compositionMappings); + } + } + + return dedupeMappings(mappings); +}; + +/** + * Represents a parsed path segment for complex nested property access. + */ +type PathSegment = + | { name: string; type: 'property' } + | { type: 'array' } + | { type: 'additionalProps' }; + +/** + * Parses a complex path like "parent[*].child.grandchild[*].prop" into segments. + */ +const parsePath = (path: string): Array => { + const segments: Array = []; + const parts = path.split(/(\[.*?\])/); + + for (const part of parts) { + if (!part) continue; + + if (part === '[*]') { + segments.push({ type: 'array' }); + } else if (/^\[.+\]$/.test(part)) { + segments.push({ type: 'additionalProps' }); + } else { + // Split by dots and add property segments + const properties = part.split('.').filter(Boolean); + for (const property of properties) { + segments.push({ name: property, type: 'property' }); + } + } + } + + return segments; +}; + +/** + * Creates a simple property mapping statement for renaming a property. + */ +const createSimplePropertyMapping = ( + baseAccess: ts.Expression, + from: string, + to: string, +): ts.Statement => { + const condition = tsc.binaryExpression({ + left: tsc.stringLiteral({ text: from }), + operator: 'in', + right: baseAccess, + }); + + const assignment = tsc.assignment({ + left: tsc.propertyAccessExpression({ + expression: baseAccess, + name: to, + }), + right: tsc.propertyAccessExpression({ + expression: baseAccess, + name: from, + }), + }); + + const deletion = ts.factory.createDeleteExpression( + tsc.propertyAccessExpression({ + expression: baseAccess, + name: from, + }), + ); + + return tsc.ifStatement({ + expression: condition, + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ expression: assignment }), + tsc.expressionToStatement({ expression: deletion }), + ], + }), + }); +}; + +/** + * Creates type guards for checking if an expression is a valid object. + */ +const createObjectGuards = ( + expression: ts.Expression, +): Array => [ + ts.factory.createBinaryExpression( + ts.factory.createTypeOfExpression(expression), + ts.SyntaxKind.EqualsEqualsEqualsToken, + ts.factory.createStringLiteral('object'), + ), + ts.factory.createBinaryExpression( + expression, + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createNull(), + ), +]; + +/** + * Combines multiple expressions with && operator. + */ +const combineWithAnd = (expressions: Array): ts.Expression => + expressions.reduce((acc, expr) => + ts.factory.createBinaryExpression( + acc, + ts.SyntaxKind.AmpersandAmpersandToken, + expr, + ), + ); + +/** + * Creates statements for normalizing top-level option slot names. + * Moves capitalized variants to the lowercase keys expected by clients. + */ +const createTopLevelSlotMappings = (): Array => { + const statements: Array = []; + const optionsId = tsc.identifier({ text: 'options' }); + + for (const { from, to } of TOP_LEVEL_SLOTS) { + const hasFrom = ts.factory.createBinaryExpression( + ts.factory.createStringLiteral(from), + ts.SyntaxKind.InKeyword, + optionsId, + ); + const hasTo = ts.factory.createBinaryExpression( + ts.factory.createStringLiteral(to), + ts.SyntaxKind.InKeyword, + optionsId, + ); + const shouldAssign = ts.factory.createPrefixUnaryExpression( + ts.SyntaxKind.ExclamationToken, + ts.factory.createParenthesizedExpression(hasTo), + ); + + const assignLower = tsc.assignment({ + left: tsc.propertyAccessExpression({ + expression: optionsId, + name: to, + }), + right: tsc.asExpression({ + expression: tsc.propertyAccessExpression({ + expression: optionsId, + name: from, + }), + type: ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + }), + }); + + const deleteFrom = ts.factory.createDeleteExpression( + tsc.propertyAccessExpression({ + expression: optionsId, + name: from, + }), + ); + + statements.push( + tsc.ifStatement({ + expression: hasFrom, + thenStatement: tsc.block({ + statements: [ + tsc.ifStatement({ + expression: shouldAssign, + thenStatement: tsc.expressionToStatement({ + expression: assignLower, + }), + }), + tsc.expressionToStatement({ expression: deleteFrom }), + ], + }), + }), + ); + } + + return statements; +}; + +/** + * Collects header parameter mappings that need case conversion. + */ +const collectHeaderMappings = ( + operation: IR.OperationObject, + outputCase: Parameters[0]['case'], +): Array => { + const mappings: Array = []; + + for (const parameterName in operation.parameters?.header) { + const parameter = operation.parameters.header[parameterName]!; + const wire = parameter.name; + const generated = stringCase({ case: outputCase, value: wire }); + if (generated !== wire) { + mappings.push({ from: generated, path: wire, to: wire }); + } + } + + return mappings; +}; + +/** + * Checks if a body type requires structured property mapping. + */ +const isStructuredBodyType = (type: string | undefined): boolean => + type === 'json' || type === 'form-data' || type === 'url-search-params'; + +/** + * Creates parameter mapping statements for path or query parameters. + */ +const createParameterMappings = ( + parameters: Record, + slotName: string, + outputCase: Parameters[0]['case'], + context: IR.Context, +): Array => { + const allStatements: Array = []; + const slotAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: slotName, + }); + + for (const parameterName in parameters) { + const parameter = parameters[parameterName]!; + const wire = parameter.name; + const generated = stringCase({ case: outputCase, value: wire }); + + // Step 1: Handle parameter name mapping (if needed) + if (generated !== wire) { + const paramRenameCondition = tsc.binaryExpression({ + left: tsc.stringLiteral({ text: generated }), + operator: 'in', + right: slotAccess, + }); + + const paramRenameAssign = tsc.assignment({ + left: tsc.propertyAccessExpression({ + expression: slotAccess, + name: wire, + }), + right: tsc.propertyAccessExpression({ + expression: slotAccess, + name: generated, + }), + }); + + const paramRenameDel = ts.factory.createDeleteExpression( + tsc.propertyAccessExpression({ + expression: slotAccess, + name: generated, + }), + ); + + allStatements.push( + tsc.ifStatement({ + expression: paramRenameCondition, + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ expression: paramRenameAssign }), + tsc.expressionToStatement({ expression: paramRenameDel }), + ], + }), + }), + ); + } + + // Step 2: Handle nested schema property mappings within this parameter + if (parameter.schema) { + const nestedMappings = collectSchemaPropertyMappings({ + context, + outputCase, + schema: parameter.schema, + }); + + if (nestedMappings.length) { + const paramAccess = tsc.propertyAccessExpression({ + expression: slotAccess, + name: wire, // Use wire name since parameter should be renamed by now + }); + + const nestedMappingStatements = generateDeepMappingStatements({ + baseAccess: paramAccess, + mappings: nestedMappings, + }); + + if (nestedMappingStatements.length) { + const paramExistsCondition = tsc.binaryExpression({ + left: tsc.stringLiteral({ text: wire }), + operator: 'in', + right: slotAccess, + }); + + allStatements.push( + tsc.ifStatement({ + expression: paramExistsCondition, + thenStatement: tsc.block({ + statements: nestedMappingStatements, + }), + }), + ); + } + } + } + } + + return allStatements; +}; + +/** + * Creates an exported mapper function declaration. + */ +const createMapperFunction = ( + functionName: string, + statements: Array, +): ts.FunctionDeclaration => + ts.factory.createFunctionDeclaration( + [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], + undefined, + functionName, + undefined, + [ + ts.factory.createParameterDeclaration( + undefined, + undefined, + 'options', + undefined, + ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + ), + ], + undefined, + ts.factory.createBlock(statements, true), + ); + +/** + * Generates TypeScript statements for deep object property remapping. + * Handles arbitrarily complex nested property paths including arrays, additionalProperties, and deep nesting. + */ +export const generateDeepMappingStatements = (options: { + baseAccess: ts.Expression; + mappings: Array; +}): Array => { + const { baseAccess, mappings } = options; + const statements: Array = []; + + for (const { from, path, to } of mappings) { + const segments = parsePath(path); + + if (segments.length === 0) continue; + + // Handle simple property mapping case + if (segments.length === 1 && segments[0]!.type === 'property') { + statements.push(createSimplePropertyMapping(baseAccess, from, to)); + continue; + } + + // Generate complex nested access + const result = generateComplexNestedAccess({ + baseAccess, + currentSegmentIdx: 0, + from, + segments, + to, + }); + + if (result) { + statements.push(result); + } + } + + return statements; +}; + +/** + * Recursively generates nested access statements for complex paths. + */ +const generateComplexNestedAccess = (options: { + baseAccess: ts.Expression; + currentLoopVars?: Array<{ isArray: boolean; varName: string }>; + currentSegmentIdx: number; + from: string; + segments: Array; + to: string; +}): ts.Statement | null => { + const { + baseAccess, + currentLoopVars = [], + currentSegmentIdx, + from, + segments, + to, + } = options; + // Base case: we've reached the target property + if (currentSegmentIdx >= segments.length) { + return createSimplePropertyMapping(baseAccess, from, to); + } + + const segment = segments[currentSegmentIdx]!; + + if (segment.type === 'property') { + // Property access - check existence and recurse deeper + const propExists = tsc.binaryExpression({ + left: tsc.stringLiteral({ text: segment.name }), + operator: 'in', + right: baseAccess, + }); + + const nextAccess = tsc.propertyAccessExpression({ + expression: baseAccess, + name: segment.name, + }); + + // Add object check if there are more segments after this property + const hasMoreSegments = currentSegmentIdx < segments.length - 1; + const guards: Array = [propExists]; + + if (hasMoreSegments) { + guards.push(...createObjectGuards(nextAccess)); + } + + const combinedGuard = combineWithAnd(guards); + + const innerStatement = generateComplexNestedAccess({ + baseAccess: nextAccess, + currentLoopVars, + currentSegmentIdx: currentSegmentIdx + 1, + from, + segments, + to, + }); + + if (!innerStatement) return null; + + return tsc.ifStatement({ + expression: combinedGuard, + thenStatement: innerStatement, + }); + } else if (segment.type === 'array') { + // Array iteration - create for-of loop + const arrayExists = tsc.binaryExpression({ + left: tsc.stringLiteral({ text: 'length' }), + operator: 'in', + right: baseAccess, + }); + + const isArray = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier('Array'), + 'isArray', + ), + undefined, + [baseAccess], + ); + + const loopVar = tsc.identifier({ text: `item${currentLoopVars.length}` }); + + const innerStatement = generateComplexNestedAccess({ + baseAccess: loopVar, + currentLoopVars: [ + ...currentLoopVars, + { isArray: true, varName: loopVar.text! }, + ], + currentSegmentIdx: currentSegmentIdx + 1, + from, + segments, + to, + }); + + if (!innerStatement) return null; + + const loop = ts.factory.createForOfStatement( + undefined, + ts.factory.createVariableDeclarationList( + [ts.factory.createVariableDeclaration(loopVar as ts.Identifier)], + ts.NodeFlags.Const, + ), + baseAccess, + ts.factory.createBlock([innerStatement], true), + ); + + return tsc.ifStatement({ + expression: ts.factory.createBinaryExpression( + arrayExists, + ts.SyntaxKind.AmpersandAmpersandToken, + isArray, + ), + thenStatement: loop, + }); + } else if (segment.type === 'additionalProps') { + // Object.keys iteration for additionalProperties + const isObject = combineWithAnd(createObjectGuards(baseAccess)); + + const keysCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier('Object'), + 'keys', + ), + undefined, + [baseAccess], + ); + + const keyVar = tsc.identifier({ text: `key${currentLoopVars.length}` }); + const valueAccess = ts.factory.createElementAccessExpression( + baseAccess, + keyVar as ts.Expression, + ); + + const innerStatement = generateComplexNestedAccess({ + baseAccess: valueAccess, + currentLoopVars: [ + ...currentLoopVars, + { isArray: false, varName: keyVar.text! }, + ], + currentSegmentIdx: currentSegmentIdx + 1, + from, + segments, + to, + }); + + if (!innerStatement) return null; + + const loop = ts.factory.createForOfStatement( + undefined, + ts.factory.createVariableDeclarationList( + [ts.factory.createVariableDeclaration(keyVar as ts.Identifier)], + ts.NodeFlags.Const, + ), + keysCall, + ts.factory.createBlock([innerStatement], true), + ); + + return tsc.ifStatement({ + expression: isObject, + thenStatement: loop, + }); + } + + return null; +}; + +interface RequestKeyMapperOptions { + operation: IR.OperationObject; + plugin: HeyApiSdkPlugin['Instance']; +} + +interface TopLevelSlot { + from: string; + to: string; +} + +const TOP_LEVEL_SLOTS: ReadonlyArray = [ + { from: 'Path', to: 'path' }, + { from: 'Query', to: 'query' }, + { from: 'Headers', to: 'headers' }, + { from: 'Url', to: 'url' }, + { from: 'Body', to: 'body' }, +] as const; + +/** + * Creates a shared requestKeyMapper function in a separate file and returns a reference to it. + * This function generates the mapper function once and stores it in a shared mappers file, + * then returns an identifier that operations can import and use. + */ +export const createRequestKeyMapper = ({ + operation, + plugin, +}: RequestKeyMapperOptions): + | { file: ICodegenFile; placeholder: string } + | undefined => { + if (!plugin.config.preserveWireCasing) return; + + const outputCase = plugin.context.config.output?.case as + | Parameters[0]['case'] + | undefined; + + if (!outputCase) return; + + // Create the shared mappers file + const mappersFile = plugin.gen.createFile(`${plugin.output}RequestMappers`, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), + }); + + // Generate a unique function name for this operation's mapper + const mapperFunctionName = `${operation.id}RequestKeyMapper`; + + // Check if we already generated this mapper + const existingSymbol = mappersFile.selectSymbolFirst([ + plugin.name, + 'requestKeyMapper', + operation.id, + ]); + if (existingSymbol) { + return { + file: mappersFile, + placeholder: existingSymbol.placeholder, + }; + } + + const mapperStatements: Array = []; + + // Normalize top-level option slot names in case output.case affected them. + mapperStatements.push(...createTopLevelSlotMappings()); + + // Header property mappings + const headerMappings = collectHeaderMappings(operation, outputCase); + if (headerMappings.length) { + // Seed headers from capitalized `Headers` slot if present + const hasHeadersCap = ts.factory.createBinaryExpression( + ts.factory.createStringLiteral('Headers'), + ts.SyntaxKind.InKeyword, + tsc.identifier({ text: 'options' }), + ); + + const headersCapAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'Headers', + }); + + const headersAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'headers', + }); + + const seedStatements: Array = []; + for (const { from } of headerMappings) { + const capEntryAccess = ts.factory.createElementAccessExpression( + headersCapAccess as ts.Expression, + ts.factory.createStringLiteral(from), + ); + + const hasValue = ts.factory.createBinaryExpression( + ts.factory.createTypeOfExpression(capEntryAccess), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createStringLiteral('undefined'), + ); + + const setRetDecl = tsc.constVariable({ + expression: ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + headersAccess as ts.Expression, + 'set', + ), + undefined, + [ + ts.factory.createStringLiteral(from), + ts.factory.createAsExpression( + capEntryAccess, + ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + ), + ], + ), + name: '_seedSetRet', + }); + + const setRetCheck = ts.factory.createIfStatement( + ts.factory.createBinaryExpression( + ts.factory.createTypeOfExpression( + ts.factory.createIdentifier('_seedSetRet'), + ), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createStringLiteral('undefined'), + ), + ts.factory.createBlock( + [ + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier('options'), + 'headers', + ), + ts.SyntaxKind.EqualsToken, + ts.factory.createAsExpression( + ts.factory.createIdentifier('_seedSetRet'), + ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + ), + ), + ), + ], + true, + ), + ); + + const deleteFromCap = ts.factory.createDeleteExpression(capEntryAccess); + const deleteFromCapStmt = tsc.expressionToStatement({ + expression: deleteFromCap, + }); + + seedStatements.push( + tsc.ifStatement({ + expression: hasValue, + thenStatement: tsc.block({ + statements: [setRetDecl, setRetCheck, deleteFromCapStmt], + }), + }), + ); + } + + if (seedStatements.length) { + mapperStatements.push( + tsc.ifStatement({ + expression: hasHeadersCap, + thenStatement: tsc.block({ statements: seedStatements }), + }), + ); + } + // Continue with canonical header remapping from generated → wire names + const headersAccess2 = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'headers', + }); + + for (const { from, to } of headerMappings) { + const slotAccess = headersAccess2; + + // const _val = headers.get(from); + const valDecl = tsc.constVariable({ + expression: ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + slotAccess as ts.Expression, + 'get', + ), + undefined, + [ts.factory.createStringLiteral(from)], + ), + name: '_val', + }); + + // if (_val !== null) { const _setRet = headers.set(to, _val as any); if (typeof _setRet !== 'undefined') options.headers = _setRet as any; if ('delete' in headers) { const _delRet = headers.delete(from); if (typeof _delRet !== 'undefined') options.headers = _delRet as any; } } + const setRetDecl = tsc.constVariable({ + expression: ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + slotAccess as ts.Expression, + 'set', + ), + undefined, + [ + ts.factory.createStringLiteral(to), + ts.factory.createAsExpression( + ts.factory.createIdentifier('_val'), + ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + ), + ], + ), + name: '_setRet', + }); + const setRetCheck = ts.factory.createIfStatement( + ts.factory.createBinaryExpression( + ts.factory.createTypeOfExpression( + ts.factory.createIdentifier('_setRet'), + ), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createStringLiteral('undefined'), + ), + ts.factory.createBlock( + [ + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier('options'), + 'headers', + ), + ts.SyntaxKind.EqualsToken, + ts.factory.createAsExpression( + ts.factory.createIdentifier('_setRet'), + ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), + ), + ), + ), + ], + true, + ), + ); + + const deleteCheck = ts.factory.createIfStatement( + ts.factory.createBinaryExpression( + ts.factory.createStringLiteral('delete'), + ts.SyntaxKind.InKeyword, + slotAccess as ts.Expression, + ), + ts.factory.createBlock( + [ + tsc.constVariable({ + expression: ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + slotAccess as ts.Expression, + 'delete', + ), + undefined, + [ts.factory.createStringLiteral(from)], + ), + name: '_delRet', + }), + ts.factory.createIfStatement( + ts.factory.createBinaryExpression( + ts.factory.createTypeOfExpression( + ts.factory.createIdentifier('_delRet'), + ), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createStringLiteral('undefined'), + ), + ts.factory.createBlock( + [ + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier('options'), + 'headers', + ), + ts.SyntaxKind.EqualsToken, + ts.factory.createAsExpression( + ts.factory.createIdentifier('_delRet'), + ts.factory.createKeywordTypeNode( + ts.SyntaxKind.AnyKeyword, + ), + ), + ), + ), + ], + true, + ), + ), + ], + true, + ), + ); + + mapperStatements.push( + valDecl, + ts.factory.createIfStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier('_val'), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.factory.createNull(), + ), + ts.factory.createBlock([setRetDecl, setRetCheck, deleteCheck], true), + ), + ); + } + } + + // Path parameter property mappings + if (operation.parameters?.path) { + const statements = createParameterMappings( + operation.parameters.path, + 'path', + outputCase, + plugin.context, + ); + + if (statements.length) { + const pathAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'path', + }); + + mapperStatements.push( + tsc.ifStatement({ + expression: pathAccess, + thenStatement: tsc.block({ statements }), + }), + ); + } + } + + // Query parameter property mappings + if (operation.parameters?.query) { + const statements = createParameterMappings( + operation.parameters.query, + 'query', + outputCase, + plugin.context, + ); + + if (statements.length) { + const queryAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'query', + }); + + mapperStatements.push( + tsc.ifStatement({ + expression: queryAccess, + thenStatement: tsc.block({ statements }), + }), + ); + } + } + + // Body property mappings for structured bodies + if (operation.body && isStructuredBodyType(operation.body.type)) { + const bodyMappings = operation.body.schema + ? collectSchemaPropertyMappings({ + context: plugin.context, + outputCase, + schema: operation.body.schema, + }) + : []; + + if (bodyMappings.length) { + const bodyAccess = tsc.propertyAccessExpression({ + expression: tsc.identifier({ text: 'options' }), + name: 'body', + }); + + const statements = generateDeepMappingStatements({ + baseAccess: bodyAccess, + mappings: bodyMappings, + }); + + if (statements.length) { + mapperStatements.push( + tsc.ifStatement({ + expression: bodyAccess, + thenStatement: tsc.block({ statements }), + }), + ); + } + } + } + + if (mapperStatements.length === 0) { + return undefined; + } + + // Create a symbol for this mapper function + const mapperSymbol = mappersFile.addSymbol({ + name: mapperFunctionName, + selector: [plugin.name, 'requestKeyMapper', operation.id], + }); + + // Generate the mapper function + const mapperFunction = createMapperFunction( + mapperSymbol.placeholder, + mapperStatements, + ); + mapperSymbol.update({ value: mapperFunction }); + + return { + file: mappersFile, + placeholder: mapperSymbol.placeholder, + }; +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts index d83fd1b55..b2ce52ea2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts @@ -106,6 +106,16 @@ export type UserConfig = Plugin.Name<'@hey-api/sdk'> & { * @default 'fields' */ responseStyle?: 'data' | 'fields'; + /** + * Preserve original casing from the input specification when sending over the wire. + * + * When enabled, the generated SDK can still expose frontend-friendly casing + * (as controlled by `output.case`), but HTTP requests will use the original + * field names from the spec for path/query/headers/body. + * + * @default false + */ + preserveWireCasing?: boolean; /** * Transform response data before returning. This is useful if you want to * convert for example ISO strings into Date objects. However, transformation @@ -281,6 +291,16 @@ export type Config = Plugin.Name<'@hey-api/sdk'> & { * @default 'fields' */ responseStyle: 'data' | 'fields'; + /** + * Preserve original casing from the input specification when sending over the wire. + * + * When enabled, the generated SDK can still expose frontend-friendly casing + * (as controlled by `output.case`), but HTTP requests will use the original + * field names from the spec for path/query/headers/body. + * + * @default false + */ + preserveWireCasing: boolean; /** * Transform response data before returning. This is useful if you want to * convert for example ISO strings into Date objects. However, transformation