openapi-react-query-codegen icon indicating copy to clipboard operation
openapi-react-query-codegen copied to clipboard

Send "types+transform" to hey-api-openapi-ts when useDateType is enabled

Open AnderssonPeter opened this issue 1 year ago • 5 comments

Resolves: #137

I'm a bit unsure of how to test that it works correctly, do you have any idea´s?

AnderssonPeter avatar Aug 14 '24 09:08 AnderssonPeter

After fiddeling around a bit, it does not look like a responseTransformer is generated..

I added

born:
  type: string
  format: date-time

to pet and --useDateType to generate:api the type changes to Date in the definition, but no transformer is generated

AnderssonPeter avatar Aug 14 '24 09:08 AnderssonPeter

Is there some way to attach a debugger when generating code?

AnderssonPeter avatar Aug 14 '24 11:08 AnderssonPeter

Is there some way to attach a debugger when generating code?

@AnderssonPeter

By outputting the source map during the build with a command like tsc -p tsconfig.json --sourceMap and creating the following launch.json in VSCode, you can attach the debugger.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch via npm",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceFolder}/examples/react-app",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run-script",
        "generate:api"
      ]
    }
  ]
}

7nohe avatar Sep 16 '24 06:09 7nohe

What is the status of this PR?

is there anyway to add the date transformers in the current codegen version?

maniator avatar Apr 04 '25 19:04 maniator

@7nohe I have tried your suggestions above, but sadly no transformation code is generated. I see that this project uses a old version of @hey-api/openapi-ts, the current version uses plugins to add transformations.. the question is if that would solve the issue or not?

So something must be missing as just setting config.types.dates to types+transform does not generate the needed code.

FYI: @maniator

AnderssonPeter avatar Apr 07 '25 10:04 AnderssonPeter