openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Transformers for dates are never executed on request

Open putnap opened this issue 8 months ago • 1 comments

Description

I have configured openap-ts to transform date fields and transformers are genereated and even supplied to SDK clients, however I am unable to observe the transformers being called. I've modified them to even print to console but nothing happens. I'm actually lost here.

Reproducible example or configuration

Here is my config:

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

export default defineConfig({
  input: 'apps/api/docs/swagger.json',
  output: {
    format: 'prettier',
    lint: 'eslint',
    path: 'libs/api-contracts/src',
  },
  plugins: [
    ...defaultPlugins,
    {
      dates: true,
      name: '@hey-api/transformers',
    },
    '@tanstack/react-query',
    '@hey-api/client-axios',
    {
      name: '@hey-api/sdk',
      transformer: true,
    },
  ],
});

Hopefully this is enough of specification

definitions:
  MachineShiftData:
    properties:
      movement_results:
        items:
          $ref: '#/definitions/MovementResult'
        type: array
    required:
    - movement_results
    type: object
  MovementResult:
    properties:
      created_at:
        format: date-time
        type: string
      id:
        type: string
      machine_id:
        type: string
      result:
        allOf:
        - $ref: '#/definitions/Unit'
        enum:
        - pair
        - left
        - right
        - none
        - closed
      station_id:
        type: string
    required:
    - created_at
    - id
    - machine_id
    - result
    - station_id
    type: object
  Unit:
    enum:
    - pair
    - left
    - right
    - none
    - closed
    type: string
    x-enum-varnames:
    - Pair
    - Left
    - Right
    - None
    - Closed

paths:
  /api/machines/{machineId}/shift-data:
    get:
      consumes:
      - application/json
      parameters:
      - description: Machine Id
        in: path
        name: machineId
        required: true
        type: string
      - description: list movements from date
        in: query
        name: from
        type: string
      - description: list movements to date
        in: query
        name: to
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/MachineShiftData'
      security:
      - oauth: []
      summary: Get shift data for a machine
      tags:
      - machines

And here is the generated code:

export const getApiMachinesByMachineIdRecordings = <
  ThrowOnError extends boolean = false
>(
  options: Options<GetApiMachinesByMachineIdRecordingsData, ThrowOnError>
) => {
  return (options.client ?? _heyApiClient).get<
    GetApiMachinesByMachineIdRecordingsResponse,
    unknown,
    ThrowOnError
  >({
    security: [
      {
        scheme: 'bearer',
        type: 'http',
      },
    ],
    responseTransformer: getApiMachinesByMachineIdRecordingsResponseTransformer,
    url: '/api/machines/{machineId}/recordings',
    ...options,
  });
};

OpenAPI specification (optional)

No response

System information (optional)

@hey-api/openapi-ts v0.64.4 @hey-api/client-axios v0.6.1 Node v22.13.1

putnap avatar Feb 20 '25 21:02 putnap