Skip to content

BigInt transformer partially broken #3731

@jeremiasjutz

Description

@jeremiasjutz

Description

When generating the transformers for bigints, the generated output is wrong if the input is a primitive array.

Generated output:

data.primitiveArray = data.primitiveArray.map((item: any) => {
  BigInt(item.toString());
  return item;
});

Fixed generated output should return the transformed value, not the original:

data.primitiveArray = data.primitiveArray.map((item: any) => {
  return BigInt(item.toString());
});

If the input is an array of objects, the transform works correctly

data.images = data.images.map((item: any) =>
  imageSchemaResponseTransformer(item),
);

const imageSchemaResponseTransformer = (data: any) => {
  data.id = BigInt(data.id.toString());
  return data;
};

Reproducible example or configuration

package version

"@hey-api/openapi-ts": "0.95.0"

config

import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
  input: {
    path: process.env.API_DOCS_PATH,
  },
  output: {
    path: "src/lib/api/client",
    postProcess: ["prettier", "biome:lint"],
  },
  plugins: [
    "@tanstack/react-query",
    "zod",
    {
      dates: false,
      bigInt: true,
      name: "@hey-api/transformers",
    },
    {
      name: "@hey-api/sdk",
      transformer: true,
    },
  ],
});

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Labels

bug 🔥Broken or incorrect behavior.needs info ⏳More information needed.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions