diff --git a/.changeset/two-cooks-kiss.md b/.changeset/two-cooks-kiss.md new file mode 100644 index 000000000..90a76f087 --- /dev/null +++ b/.changeset/two-cooks-kiss.md @@ -0,0 +1,6 @@ +--- +'@hey-api/client-fetch': patch +'@hey-api/openapi-ts': patch +--- + +fix: handle async response transformers diff --git a/packages/client-axios/src/index.ts b/packages/client-axios/src/index.ts index 5ce59a463..5e3f8bdcf 100644 --- a/packages/client-axios/src/index.ts +++ b/packages/client-axios/src/index.ts @@ -226,7 +226,7 @@ export const request = ( let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody); + transformedBody = await options.responseTransformer(responseBody); } const result: ApiResult = { diff --git a/packages/client-core/src/types.ts b/packages/client-core/src/types.ts index 45356960c..ad0d657f5 100644 --- a/packages/client-core/src/types.ts +++ b/packages/client-core/src/types.ts @@ -26,7 +26,7 @@ export type ApiRequestOptions = { readonly path?: Record; readonly query?: Record; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly url: string; }; diff --git a/packages/client-fetch/src/index.ts b/packages/client-fetch/src/index.ts index 4c103e81d..1d9fd04eb 100644 --- a/packages/client-fetch/src/index.ts +++ b/packages/client-fetch/src/index.ts @@ -122,7 +122,7 @@ export const createClient = (config: Config): Client => { let data = await response[parseAs](); if (parseAs === 'json' && options.responseTransformer) { - data = options.responseTransformer(data); + data = await options.responseTransformer(data); } return { diff --git a/packages/client-fetch/src/types.ts b/packages/client-fetch/src/types.ts index 043902548..d5f25843a 100644 --- a/packages/client-fetch/src/types.ts +++ b/packages/client-fetch/src/types.ts @@ -90,8 +90,12 @@ export interface Config * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; - - responseTransformer?: (data: unknown) => unknown; + /** + * A function for transforming response data before it's returned to the + * caller function. This is an ideal place to post-process server data, + * e.g. convert date ISO strings into native Date objects. + */ + responseTransformer?: (data: unknown) => Promise; } interface RequestOptionsBase extends Omit { diff --git a/packages/openapi-ts/src/compiler/types.ts b/packages/openapi-ts/src/compiler/types.ts index 3f7ed0a18..f34504a46 100644 --- a/packages/openapi-ts/src/compiler/types.ts +++ b/packages/openapi-ts/src/compiler/types.ts @@ -108,12 +108,14 @@ export const toParameterDeclarations = (parameters: FunctionParameter[]) => * Create Function type expression. */ export const createFunction = ({ + async, comment, multiLine, parameters = [], returnType, statements = [], }: { + async?: boolean; comment?: Comments; multiLine?: boolean; parameters?: FunctionParameter[]; @@ -121,7 +123,7 @@ export const createFunction = ({ statements?: ts.Statement[]; }) => { const expression = ts.factory.createArrowFunction( - undefined, + async ? [ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword)] : undefined, undefined, toParameterDeclarations(parameters), returnType ? createTypeNode(returnType) : undefined, diff --git a/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs b/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs index 72f2e44ef..2c83c55dd 100644 --- a/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs +++ b/packages/openapi-ts/src/templates/core/ApiRequestOptions.hbs @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; diff --git a/packages/openapi-ts/src/templates/core/angular/request.hbs b/packages/openapi-ts/src/templates/core/angular/request.hbs index 12ab72957..ff9727aa5 100644 --- a/packages/openapi-ts/src/templates/core/angular/request.hbs +++ b/packages/openapi-ts/src/templates/core/angular/request.hbs @@ -80,7 +80,7 @@ export const request = (config: OpenAPIConfig, http: HttpClient, options: Api let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } return { diff --git a/packages/openapi-ts/src/templates/core/axios/request.hbs b/packages/openapi-ts/src/templates/core/axios/request.hbs index 16356aa56..20dddece6 100644 --- a/packages/openapi-ts/src/templates/core/axios/request.hbs +++ b/packages/openapi-ts/src/templates/core/axios/request.hbs @@ -84,7 +84,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions, let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/src/templates/core/fetch/request.hbs b/packages/openapi-ts/src/templates/core/fetch/request.hbs index 0af1d96f5..51149db42 100644 --- a/packages/openapi-ts/src/templates/core/fetch/request.hbs +++ b/packages/openapi-ts/src/templates/core/fetch/request.hbs @@ -82,7 +82,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/src/templates/core/xhr/request.hbs b/packages/openapi-ts/src/templates/core/xhr/request.hbs index a1a20f582..60ed59186 100644 --- a/packages/openapi-ts/src/templates/core/xhr/request.hbs +++ b/packages/openapi-ts/src/templates/core/xhr/request.hbs @@ -80,7 +80,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/src/utils/write/transformers.ts b/packages/openapi-ts/src/utils/write/transformers.ts index 4b0c3a516..f9df62102 100644 --- a/packages/openapi-ts/src/utils/write/transformers.ts +++ b/packages/openapi-ts/src/utils/write/transformers.ts @@ -66,6 +66,7 @@ const ensureModelResponseTransformerExists = ( }); generateResponseTransformer({ ...props, + async: false, name, statements, }); @@ -179,12 +180,14 @@ const processModel = (props: ModelProps): ts.Statement[] => { }; const generateResponseTransformer = ({ + async, client, name, onNode, onRemoveNode, statements, }: Pick & { + async: boolean; name: string; statements: Array; }) => { @@ -205,6 +208,7 @@ const generateResponseTransformer = ({ } const expression = compiler.types.function({ + async, multiLine: true, parameters: [ { @@ -313,6 +317,7 @@ export const processResponseTransformers = async ({ path: [dataVariableName], }); generateResponseTransformer({ + async: true, client, name: nameCreated, onNode, @@ -321,7 +326,7 @@ export const processResponseTransformers = async ({ }); }, onNode, - type: `(${dataVariableName}: any) => ${name}`, + type: `(${dataVariableName}: any) => Promise<${name}>`, }); } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/request.ts.snap index aa53f09de..4eab34ab6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/request.ts.snap @@ -303,7 +303,7 @@ export const request = (config: OpenAPIConfig, http: HttpClient, options: Api let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } return { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/request.ts.snap index aa53f09de..4eab34ab6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/core/request.ts.snap @@ -303,7 +303,7 @@ export const request = (config: OpenAPIConfig, http: HttpClient, options: Api let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } return { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/request.ts.snap index 36191171a..ecc2e393c 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/request.ts.snap @@ -325,7 +325,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions, let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/request.ts.snap index 36191171a..ecc2e393c 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/core/request.ts.snap @@ -325,7 +325,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions, let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios_transform/types.gen.ts.snap index 70670037c..95bd3b551 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios_transform/types.gen.ts.snap @@ -127,7 +127,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -159,23 +159,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_transform/types.gen.ts.snap index 70670037c..95bd3b551 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_transform/types.gen.ts.snap @@ -127,7 +127,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -159,23 +159,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/request.ts.snap index 1b8291f98..fa1ed3862 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/request.ts.snap index 1b8291f98..fa1ed3862 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/request.ts.snap index f96edeeb9..5458a2899 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && response.ok) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/request.ts.snap index 7831b5bea..9b08a59cd 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap index 6dd7e3773..1758d98c4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/ApiRequestOptions.ts.snap @@ -9,6 +9,6 @@ export type ApiRequestOptions = { readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => T; + readonly responseTransformer?: (data: unknown) => Promise; readonly errors?: Record; }; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/request.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/request.ts.snap index 7831b5bea..9b08a59cd 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/request.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/core/request.ts.snap @@ -328,7 +328,7 @@ export const request = (config: OpenAPIConfig, options: ApiRequestOptions) let transformedBody = responseBody; if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = options.responseTransformer(responseBody) + transformedBody = await options.responseTransformer(responseBody) } const result: ApiResult = { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap index 2b8ee08b4..55217bd5e 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap @@ -115,7 +115,7 @@ export type $OpenApiTs = { }; }; -export type ParentModelWithDatesResponseTransformer = (data: any) => ParentModelWithDatesResponse; +export type ParentModelWithDatesResponseTransformer = (data: any) => Promise; export type ParentModelWithDatesModelResponseTransformer = (data: any) => ParentModelWithDates; @@ -147,23 +147,23 @@ export const ParentModelWithDatesModelResponseTransformer: ParentModelWithDatesM return data; }; -export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = data => { +export const ParentModelWithDatesResponseTransformer: ParentModelWithDatesResponseTransformer = async (data) => { if (data) { ParentModelWithDatesModelResponseTransformer(data); } return data; }; -export type ModelWithDatesResponseTransformer = (data: any) => ModelWithDatesResponse; +export type ModelWithDatesResponseTransformer = (data: any) => Promise; -export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = data => { +export const ModelWithDatesResponseTransformer: ModelWithDatesResponseTransformer = async (data) => { ModelWithDatesModelResponseTransformer(data); return data; }; -export type ModelWithDatesArrayResponseTransformer = (data: any) => ModelWithDatesArrayResponse; +export type ModelWithDatesArrayResponseTransformer = (data: any) => Promise; -export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = data => { +export const ModelWithDatesArrayResponseTransformer: ModelWithDatesArrayResponseTransformer = async (data) => { if (Array.isArray(data)) { data.forEach(ModelWithDatesModelResponseTransformer); }